I have 15 post-function sub-tasks that all have almost the same exact format in which I set the assignee and additional assignee(custom field).
For this particular sub-task, I cannot get the sub-task to set the assignee correctly to the username I have, instead, once the sub-task is created, the Assignee is only set to the username text and not the actual agent and if I try to select from the Assignee drop-down list, it also just lists the username text from the script and I can no longer select their normal Jira full name from the drop-down list in the parent ticket and sub-tasks related. If I go to any other ticket and/or sub-task, I can select them normally as an Assignee. Once I unassign the original sub-task or assign to someone else, I can then also select the agent from the drop-down list normally. When looking at the ticket Activity, I noticed something strange, it sets the assignee to some generic Jira Username with numbers, screenshot attached.
Below is the script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
issue.setAssigneeId("User1")
issue.setDescription("--Remove user's name from telephone description\n--Change telephone owner to anonymous\n--Delete voicemail account\n--Delete extension from AD account")
Hi @Jh ,
according to the documentation setAssigneeId expects to get userkey (not username). Your problem is probably related to the GDPR changes - new users have userkey like JIRAUSER10100 and it is not same as username anymore.
@Hana Kučerová Hmm, interesting, that does seem like the case. The user is relatively new so that explains why. What is the solution? Do I use the userKey instead or is that randomized every time?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jh ,
you can get it using groovy script like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
UserManager userManager = ComponentAccessor.getUserManager()
ApplicationUser user = userManager.getUserByName("username")
String userKey = user?.getKey()
Actually I don't know any easy way how to do it as a Jira administrator, so I asked myself here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Hana Kučerová, I found out another kind of workaround to find out the userKey. I have a DEV project and just normally set the username in the Groovy script, I then create the ticket as normal with the groovyscript in the post-function workflow and after the ticket gets created with the invalid username I set the assignee or Unassigned or myself and I can see from the Jira activity what the userKey is.
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.