AssigneeId not recognizing 20character length username

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?

2 answers

1 accepted

2 votes
Accepted answer
Chris Fuller Atlassian Team Mar 10, 2016

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.

Chris Fuller Atlassian Team Mar 10, 2016

As an example:

  1. Create user "alice" (her key is "alice")
  2. Create user "bob" (his key is "bob")
  3. Delete "alice"
  4. Rename "bob" to "alice".  Behind the scenes, this forces the old "alice" to be renamed to "alice#1", so we now have:
    key "alice" <=> username "alice#1"
    key "bob" <=> username "alice"
  5. Use "alice" in something that works with user keys


  • When you use "alice" is a username, you get the current "alice" who used to be "bob".
  • When you use "alice" as a user key, you get the old "alice" who got renamed to "alice#1".

To work with renamed users correctly, your code needs to use keys and usernames correctly.  You've used the wrong one, here.

According to  select * from cwd_user where user_name like '%sramdocscoordinator%' the only entry is the ID=53942 / USER_NAME=csramdocscoordinator


Chris Fuller Atlassian Team Mar 10, 2016

A deleted user would not be in cwd_user anymore.  You would find the record in app_user.

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.

smile thanks

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




Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Jan 15, 2019 in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

268 views 4 2
Join discussion

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