Hi all,
We're using JSM on cloud and exploring ScriptRunner to update 2 fields based on the selection on a cascading custom field.
I started with this code in Script Console...
// test to update Resolver group and Functional area
def issueKey = 'TEST-37'
// Fetch the issue object from the key
def result = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
.fields
//def fields = issue.fields as Map
Category_parent = result.customfield_10220.value
Category_child = result.customfield_10220.child.value
logger.info ("Parent value: ${Category_parent}")
logger.info ("Child value: ${Category_child}")
//def Category_parent = 'Issue category'.value
if (Category_parent == "Application (Non-SAP)" && 'Category_child' == "Jira") {
def func_area = "Technology"
def resol_grp = "Jira Administrator"
}
else if (Category_parent == "Enterprise Data Management" ) {
def func_area = "Enterprise Data Management"
def resol_grp = "EDM"
}
else if (Category_parent == "Application (SAP)" && Category_child == "OpenText" ) {
def func_area = "Corporate"
def resol_grp = "SAP Finance Management"
}
else if (Category_parent == "Warehouse Management" && Category_child == "Dematic" ) {
def func_area = "Supply Chain"
def resol_grp = "SAP Warehouse Management"
}
else { //it always end up here without processing the update on the fields below
def func_area = "Technology"
def resol_grp = "IT Service Desk"
return "No updates done"
}
put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
"Functional area": func_area,
"Resolver group" : resol_grp
]
])
.asString()
logger.info ("Functional area: ${func_area}")
logger.info ("Resolver group: ${resol_grp}")
My script above always end up in the last ELSE block and will not process the PUT (or update) block.
What am I doing wrong? Please help.
Regards,