How to assign an issue to a user using Script runner for Cloud?

miller j June 27, 2019

Hello,

How to assign an issue to a user using Script runner for Cloud?

This used to work, but it stopped at some point:

def user = [name: "Johnt"]
issue.fields.assignee = user

Thanks

3 answers

1 vote
cgadade April 14, 2020

Hi @miller j ,

  Instead of User name ,please enter user id on jira cloud,

procedure to get user id:

1.Click on user name

2.Go to tab

3.You will get an id 

 

e.g .

 

issueInput.fields.assignee = [id:'123456:12345a67-bbb1-12c3-dd45-678ee99f99g0'] as Map

 

Just one question ,

Do you know how to copy custom field value while creating new issue in jira cloud using clone post function .

Jacques B May 26, 2022

Hi @cgadade ,

I tried to follow your steps, but I do not see a user name anywhere.

When I go to Settings > User Management in Jira Cloud, I get the list of all users. When I click on a user I only see Full name, Email address and Nickname.

Is the Nickname unique and non-editable?

If not, how do you uniquely reference a user in a script?

Jacques B May 26, 2022

No worries, I found the accountID value in the user's URL.

0 votes
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 5, 2019

Hi Miller J,

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.

Regards,

Kristian

0 votes
Payne
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 28, 2019

Here is how I get a user by username, which you may find useful.

ApplicationUser user = ComponentAccessor.getUserManager().getUserByName("bsmith")

miller j June 28, 2019

Hi @Payne  Is this for Jira Cloud?

Payne
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 28, 2019

I use it for server; hopefully it will work for cloud, but I'm not sure. Give it a whirl and see.

miller j June 28, 2019

No it wont work, Cloud uses API's for scripting.

Like Jacques B likes this

Suggest an answer

Log in or Sign up to answer