I've created a Script Runner Clone post function in my workflow. In the 'Additional issue actions' I have 'issue.assigneeId = "csramdocscoordinator"'
but when the ticket is created, it does not link to the user with this Id. instead it shows 'csramdocscoordinator#1' in the Assignee field.
How do I get it to recognize the Id correctly?
The "#1" comes from the automated rename of the userkey <=> username mapping that we hold onto for deleted accounts. If you rename a user such that you reclaim a username that previously belonged to somebody else, the mapping for the old owner gets #1, #2, etc. added to it until we find one that gets it out of the way. This is because we still keep the mapping for deleted users in case something is still referencing them and tries to look them up later.
The assigneeId is probably supposed to be the user's key, not the user's name, so you are setting it to the wrong account. You can use UserKeyService.getKeyForUsername to find the correct value.
As an example:
Now:
To work with renamed users correctly, your code needs to use keys and usernames correctly. You've used the wrong one, here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
According to select * from cwd_user where user_name like '%sramdocscoordinator%' the only entry is the ID=53942 / USER_NAME=csramdocscoordinator
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A deleted user would not be in cwd_user anymore. You would find the record in app_user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, this worked. I looked in app_user for lower_user_name like '%sramdocscoordinator%' and found two User_Keys 'csramdocscoordinator' (the original) and 'sramdocscoordinator' (new value)
the 'csramdocscoordinator#1' that I was getting is tied to the csramdocscoordinator Id. So I used
issue.assigneeId = "sramdocscoordinator"
and the correct user is now in the tickets.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kevin,
Using the issue.assigneeId method expects the ID of the user as a paramater and not the username of the user as described here.
What you should look to do is to get a new user object for the user and set this using the issue.assignee method as shown below.
import com.atlassian.jira.component.ComponentAccessor // Get the User we want to set as the Assignee on the cloned issue def user = ComponentAccessor.getCrowdService().getUser(("kwalker")) // Set the Assignee based on the username and not by key. issue.assignee = user
image2016-3-11 11:27:16.png
I hope this helps
Thanks
Kristian
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.