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

2 votes
Accepted answer

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.

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

0 votes

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.

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. 

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! 

0 votes

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
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,699 views 3 11
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