Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Updating Approvers in Help Desk via ScriptRunner Cloud

Ryan Yoshioka February 27, 2018

Trying to update the default approver field that comes with Help Desk. For my instance of JIRA Cloud the custom field is 'customfield_10029'. I attached a screenshot of the structure and my script listener below. The script listener isn't throwing any errors but it isn't setting the approver field either. I've tried the same script with another user pick list and it works as intended. Would definitely like to leverage the "Approver" field instead of another user pick list. 

I thought I was matching the structure of the custom fields properly, but when the script is triggered the approver field isn't being set properly. 

How can I properly set the approver field via scriptrunner? 

Thanks!

Structure of customfields:

Screen Shot 2018-02-26 at 18.35.25 PM.png

Screen Shot 2018-02-27 at 11.36.00 AM.png 

Script Listener:

def approverID = 'customfield_10029'
def approvalsID = 'customfield_10015'
def userApprover = ""

def value1 = issue.fields.customfield_16125.value as String
if (value1 == "Santa Claus"){
userApprover = "santa"
} else {
userApprover = "joe"
}

put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(approverID):[{
name: userApprover
}],
(approvalsID): [{
canAnswerApproval: true
approvers: [{
approver:{
name: userApprover
}
}]
}]
]
])
.asString() 

Edit: Realized that a second custom field is attached the approver field for helpdesk.

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 5, 2018

Hi Ryan,

Unfortunately the Approvers field is a locked field owned by the Jira Service Desk.

Service desk fields need to be updated using the Jira Service Desk Cloud Rest API located  here, however unfortunately there is no rest call provided to update the Approvers field which means that it cannot be set using ScriptRunner for Jira Cloud. 

Thanks

Kristian

Ryan Yoshioka March 5, 2018

Thanks Kristian,

Appreciate the help! 

 

For those that run into a similar problem, as a workaround I created a custom user picker field. Set that user field for the approver at the step in the workflow and setting the value with Scriptrunner. 

Joao Zampa June 14, 2020

@Ryan Yoshioka 
What is the structure to be used to update a User Picker field?

I am a new user and I am I little confuse how to update it.

I am using the structure below for testing, the reporter I was able to set the user by using the AccountID field, but for the CF customfield_11410 it is removing the user and leaving it blank.

My goal is to be able to add multiple users inside a multiple user picker custom field.

Screen Shot 2020-06-14 at 5.39.22 PM.png

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2020

Hi Joao,

I can confirm we have an example script located here which can be run on the Script Console as the ScriptRunner add on user and shows how to set a Multi User Picker field by passing the array of users account ID's and you will be able to use this script as a reference guide to help you create the script that you require. 

I hope this information helps.

Regards,

Kristian

Rob Tucker November 2, 2020

It seems that the example above does not work for setting the Approver inside of Service Desk. Is there still no way to do this in jira cloud?

 

Thanks!

TAGS
AUG Leaders

Atlassian Community Events