Forums

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

JMWE set field value - conditional execution problem

Anna Robinson
Contributor
November 23, 2018

I am setting up a very simple post function using the JMWE extension to set the assignee based on a value in my custom field.

I have confirmed that my conditional logic works, however, when it tries to set the assignee  it can not find the user. 

I have tried different syntax (First name last name, email address, "@First name last name") for assignee and nothing seems to work.

 

The value(s) of field Assignee of the current issue will be set to Anna Robinson (replacing existing values). Send notification. 
Run as add-on user.

Run this post-function conditionally:

issue.fields["Product Area Test"].value == "Admin"

 

The error I get is:

Incorrect request: {"assignee":"User 'Anna Robinson' does not exist."}

 

 

Is there specific syntax that I should be using to get this to work? 

2 answers

1 accepted

0 votes
Answer accepted
Anna Robinson
Contributor
November 23, 2018

The final resolution was to use the username value which can only be found inside the URL on the admin edit user page /admin/users/view?username=X.

0 votes
Thomas Schlegel
Community Champion
November 23, 2018

Hi @Anna Robinson,

you can set the assignee like this:

import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getUserManager().getUserByKey("username")
issue.setFieldValue("Assignee", user)

I would not use the first, last or display name in the script, use the shortname, the name the user is using for login.

Anna Robinson
Contributor
November 23, 2018

Sorry - I am pretty new to the backend configuration of JIRA, but this is the screen that I am using to configure the JMWE.

The assignee field is just taking a value inside a field. 

 

image.png

David Fischer
Community Champion
November 23, 2018

Hi Anna,

you need to specify the username of the user. The username is only visible on the user's Profile page.

This will change early next year, when Atlassian will be removing usernames (among other things), and you will need to specify an accountId instead.

Anna Robinson
Contributor
November 23, 2018

Thank you, that worked.
Wow, that was not very intuitive at all.

For anyone else struggling with this, the only place you can see the username is actually inside the URL on the admin edit user page /admin/users/view?username=X.

David Fischer
Community Champion
November 23, 2018

It used to be displayed on the User management page but Atlassian removed it recently, in preparation for the GDPR changes.

Thomas Schlegel
Community Champion
November 23, 2018

@Anna Robinson, I thought you needed a scripted workflow function, that‘s why I posted the code.

Lilian Brouwer
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!
November 18, 2021

@Thomas Schlegel I wonder where you can script the workflow function could you tell me where I can find that?

Suggest an answer

Log in or Sign up to answer