assign issue to the user


There is a script, which takes values from the issue and creates a similar one with the same assignee, reporter, ect. Now we have a problem with users, which usernames were changed in Active Directory. There is a following error while creating: 

Assertion failed:
assert !validationResult.errorCollection.hasAnyErrors()

Errors: {assignee=User '' does not exist.}

Error Messages: []


"sam" is the original username, but the current one is "sam.smith". 

I'm using getUserByKey() method to get an assignee and reporter values. 

So, what can I use to cover such a problem? Would the method getUserByName() reliable if the User Name is changed? Which column referrs to this method? 

The code looks like: 

def customFieldManager = ComponentAccessor.getCustomFieldManager()

    //current issue
	Issue issue  = issue
	def rep = issue.getReporterId() 
	def assign = issue.getAssigneeId()
//........ creating new issue 
				// ..... 
			reporterId =  rep
            assigneeId = assign 
			// .....

Thanks in advance. 

6 answers

1 accepted

This widget could not be displayed.

So it seems:



are two different things. The first returns the key and the second returns an actual id. Try using:

It seems like setAssigneeId looks at the username, as you described.

This widget could not be displayed.
Vasiliy Zverev Community Champion Oct 06, 2016

Try to use setAssignee() method instead of setAssigneeId().

This widget could not be displayed.

The assignee and reporter id should be the user key. Are you sure this is whats breaking your script? It should continue working even when users have been renamed.

This widget could not be displayed.

Hi Adam, 

Yes, I'm almost sure. We have several users with changed usernames and only for these ones the script returns error. 

Moreover, we have the following case: 


1st user renamed (from original -> to current) : sam    ---> sam.smith  

2nd user renamed (from original -> to current): ---> sam  


And, if Assignee (or reporter) is user with current username sam.smith , for new issue the assignee will be the user with username sam . If Reporter (or assignee) is user sam , the system returns me that user  doesnt exist. It looks like the getUserByKey takes the original (previous, user_key) value, and when parses it to the new issue, searchs between current usernames (lower_user_name). 

These users could be found in database, 

select * from app_user
where user_key <> lower_user_name

And for all these users the described problem exsists. 

This widget could not be displayed.

Yes, I've tried to use and returned these values to the comment to see which value this method will return, seems that it works properly. 

Thank you! 

This widget could not be displayed.

Hi Saida, Glad you got it working. I have converted my comment to an answer. Would you be able to accept so other people get to see the solution too? Thanks.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

721 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you