Forums

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

Setting multiple user custom field value via postfunction

Gleb Kartashov
Contributor
July 26, 2019

Hi!

I have a JMWE Wokrflow post function "Set field value (Groovy)". In my function i need to set a value of a custom "Multiple user picker". The code is working perfectly fine and returning an ArrayList with user names, but the field doesn't show up when viewing an issue.image.pngimage.png

What type of value should I return to the Result variable in order to fill a multiple users field?

1 answer

0 votes
Radhika Vijji _Innovalog_
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.
July 26, 2019

Hi Gleb,

To set a multi-user picker field, you need to return a comma-separated usernames or a collection of ApplicationUser objects. Do you see any error in the log (atlassian-jira.log file) file? You can activate the error reporting in the post-function configuration (scroll down to the end of the post-function configuration), save the post-function, publish the workflow and retry. The error will be shown on the issue view screen/ transition screen after you trigger the transition. Also, did you check that the field is available on the issue view screen? 

Regards,

Radhika

Gleb Kartashov
Contributor
July 26, 2019

Hi!

Thanks for responding, I'll modify the script to return usernames.

While you're at it, can you please tell me what is going on here:

adm1.PNGadm2.PNGadm3.PNG

The same user, but getUserByName method is literally not working?

Like André Costa likes this
Radhika Vijji _Innovalog_
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.
July 26, 2019

"Administrator" is the display name and "admin2" is the username. And the method expects the username.

Regards,

Radhika

David Fischer
Community Champion
July 26, 2019

Actually, in the second screenshot, "admin2" is the user key, which is an immutable user identifier - the username is also unique, but can be modified by the user or the administrator. 

The getUserByName method expects a username (which is what you input on the Jira login screen), and the getUserByKey expects a user key, which is really an internal id. Note that, by default, the user key is the lowercase version of the username, but since the username can be changed, they might end up being completely different.

Suggest an answer

Log in or Sign up to answer