Our Jira is integrated with our Active Directory. When our IT dept creates a new user in the Active Directory, the username (email) will be available in Jira.
When an Active Directory name is first created, Jira will make a record of it (lets call it username-contractor). My post functions works when I make issue assignments using one of these 2 functions:
issue.assigneeId = 'username-contractor'
Or issue.setAssigneeId("username-contractor")
But let's say the IT dept changes the user name at a later date to "username".
I can still use the functions as before and it works:
issue.assigneeId = 'username-contractor'
Or issue.setAssigneeId("username-contractor")
When in the ticket I hover over the assignee, I can see their new username and not the old username-contractor
Then I try to update my script and use the new username like below:
issue.assigneeId = 'username'
Or issue.setAssigneeId("username")
But when I do that It appears that I cannot use the same functions with the new username. As a result the ticket will not get assigned to the user.
So my question is, it is clear to me that Jira keeps 2 records of the user. What function can I use to set the assignee to the new username?
Appreciate any feedback.
Hello,
You would need to do it like this:
import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getUserManager().getUserByName("username");
issue.setAssignee(user);
This post function must be first in the list of post functions and this post function must not be in the create issue transition.
Thanks Alexey. Unfortunately although my post function is first in the list, I have my post function in the create issue transition. The reason is I am assigning tickets to particular users when they are first created. Is there a function that can be used in the create issue transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey, after typing my reply I went ahead and implemented your solution in my create issue transition and it worked! I am using:
issue.setAssignee(ComponentAccessor.getUserManager().getUserByName("username"));
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome! If my answer helped you , kindly mark my answer as accepted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.