Forums

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

Set User Picker in Jira Service Desk with ScriptRunner Behaviour

mmr1909
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 12, 2018

How can I set one or more users to the Approvers field with a ScriptRunner behaviour?

I tried setFormValue("user1") but it did not work. Here is the code.

 

import com.atlassian.jira.component.ComponentAccessor
 

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def approversField = customFieldManager.getCustomFieldObjectByName("Approvers")

approversField.setFormValue(["user1"])

 

 

2 answers

1 accepted

0 votes
Answer accepted
Mark Markov
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.
June 13, 2018

Hello @mmr1909

To set value on the form via behaviour, you need to get FormField object like this:


def approversField = getFieldByName("Approvers")

approversField.setFormValue(["user1"])
0 votes
mmr1909
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 15, 2018

Hello @Mark Markov,

now it works! Thanks for your help.

Mark Markov
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.
June 15, 2018

Hello @mmr1909

You're welcome! If it helps you, please mark answer as accepted :)

Steve Letch September 3, 2019

Hi Mark

Would you be able to show me a simple script to pull the users into the field based on security group?

 

Preferably with an if statement based on another field. If custom field application type = x then pre fill approvers field with members of X application approvers group.

 

thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events