Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

I want to update Labels field with other custom filed value

sysadmin I'm New Here Sep 09, 2022

I built the script below in order to get value from the custom filed "sourceFieldName" then insert it to the custom filed "selectListFieldName" (Labels filed).


But unfortunately, it returns always null and the script is not able to return even the "sourceFieldName" value.


The script :

def issueKey = 'SS-43'

def issue = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')

def fields = issue.fields as Map

// Specify the name of the select list field to set
def selectListFieldName = 'customfield_10131'
def sourceFieldName = 'customfield_10116'


// Get the Custom field to get the option value from
def customField = get("/rest/api/2/field")
.find {
(it as Map).name == selectListFieldName
} as Map

def customField2 = get("/rest/api/2/field")
.find {
(it as Map).name == sourceFieldName

} as Map



def value3 = (fields[customField2] as String)?.value"${(value3)}")

//def input1 = fields[customField2].value as String

// Check if the custom field returns a valid field and is not null
assert customField != null : "Cannot find custom field with name of: ${selectListFieldName}"

// Note: - Atlassian provide examples for the syntax to set other custom field types in the documentation page at
def result = put("/rest/api/2/issue/${issueKey}")
// Uncomment the line below if you want to set a field which is not pressent on the screen. Note - If using this you must run the script as the ScriptRunner Add-On User.
//.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
fields: [
( : "${(value3)}"

if (result.status == 204) {
return "The ${} select list field was successfully updated on the ${issueKey} issue"
} else {
return "${result.status}: ${result.body}"

1 answer

0 votes

Hello @sysadmin 

Welcome to the community.

What type of field is sourceFieldName?

sysadmin I'm New Here Sep 09, 2022

Thank you Trudy

sourceFieldName is a  Number filed

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Jira Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

5,012 views 18 31
Read article

Atlassian Community Events