JIRA cloud scriptrunner workflow post function: set user picker value for custom field

Sam Ferguson June 25, 2019

I have a custom field that is type user picker, and I am trying to update the user associated with this field on issue creation. However, I have not been able to assign the user picker field. 

In the below example, my logged output shows that "updated user: 'jdoe'" but this change is not reflected on the JIRA ticket.

def username = "jdoe"

issueInput.fields.customfield_16400 = [name: username]
logger.info("updated user: " + issueInput.fields.customfield_16400)

What type does the custom field for user picker expect, and how do I go about updating it?

Please note that I use JIRA Cloud.

2 answers

1 accepted

1 vote
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.
July 2, 2019

Hi Samuel,

Thank you for your question.

I can confirm that it is no longer possible to set a user field using a users name since Atlassian recently updated their API's to make changes to comply with the GDPR legalisation as described here.

These changes means that all user references for API's have been updated to use an accountID rather than by using a name or key.

This legislation means that Atlassian has had to update all of its rest API's in order to comply with this which mandates how data is stored.

I can confirm that we have created a page in our documentation site located here which shows how you should update your scripts to be GDPR compliant and we would advise that you review this page in order to see further details of how to set a user using an accountID and can confirm that the section located here shows how to set a user field on an issue using a users account ID.

If this answer has solved your issue can you please accept it in order to mark this answer as correct for users who are searching for a similar issue.

Regards,

Kristian

1 vote
Pouján (Jiralísta) September 26, 2019

User accounid as the value when using Update Issue Custom Field.

How to get accountid:

https://[domain name].atlassian.net/rest/api/latest/user/search?query=[user email]

In the return string, which looks like this, you can spot the accountid:

[{"self":"https://[domain name].atlassian.net/rest/api/2/user?accountId=557058:1991c146-4646-43d3-98d0-xxx","key":"admin","accountId":"557058:1991c146-4646-43d3-98d0-xxx","accountType":"atlassian","name":"admin","emailAddress":"[user email]","avatarUrls":{"48x48":"https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:1991c146-4646-43d3-98d0-xxx/97b461af-8916-411e-a2a1-1f6e5e89adc7/128?size=48&s=48","24x24":"https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:1991c146-4646-43d3-98d0-4b72ee11f382/97b461af-8916-411e-a2a1-1f6e5e89adc7/128?size=24&s=24","16x16":"https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:1991c146-4646-43d3-98d0-xxx/97b461af-8916-411e-a2a1-1f6e5e89adc7/128?size=16&s=16","32x32":"https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/557058:1991c146-4646-43d3-98d0-xxx/97b461af-8916-411e-a2a1-1f6e5e89adc7/128?size=32&s=32"},"displayName":"user full name","active":true,"timeZone":"Europe/Berlin","locale":"en_US"}]
Erwin Fei March 10, 2020

Hi, could you advise the code about how to get accountId from the return string in Scriprunner?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events