Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner: Setting the Asignee field to a custom field "User Picker (single user)

carlos andrade
Contributor
February 14, 2024

I am trying to set the Assignee field to the value of a custom field that has users using ScriptRunner in a post function and it is not working. I know the custom field name and the custom field ID. Could the issue be that these fields ar not compatible?

When I try to use the ScriptRunne build-in script to copy field values, the Assignee field is not shown as a option as a target field.

1 answer

1 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2024

Hi Carlos,

Assignee is a bit of an odd one because it's not just a simple user field, it's a system field with a whole pile of protections and extra code around it.

You can't really just "copy" by editing, you have to "assign" the issue.  (The Jira UI makes it look like an edit in a lot of places!)

You are going to have to write a manual script to do this, but if you're on a recent version of Scriptrunner (one with HAPI in it), it's very short:

 

def myUser = issue.getCustomFieldValue('My user').value

issue.set {
setAssignee(myUser)
}
carlos andrade
Contributor
February 14, 2024

Hi Nic, That explains a lot. My ScriptRunner is pretty recent. I will give it a try. 

Like # people like this

Suggest an answer

Log in or Sign up to answer