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:
To work with renamed users correctly, your code needs to use keys and usernames correctly. You've used the wrong one, here.
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.
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
I hope this helps
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
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!
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