I'm trying to create a scripted field (using the Script Runner Plugin) that will show the component lead for the component selected on a given issue. According to the documentation, this is the way to do that:
import com.atlassian.jira.ComponentManager def componentManager = ComponentManager.getInstance() def issue = componentManager.getIssueManager().getIssueObject("JRA-1025") def leads = issue.componentObjects.toList() if (leads) { def lead = leads?.first()?.lead if (lead) { componentManager.getUserUtil().getUser(lead) } }
However, whenever I try this (inputting an appropriate issue key for my JIRA instance), the result just comes back as "Anonymous" every time. Has something changed since the documentation was written? What would be the best way to do this?
Community moderators have prevented the ability to post new answers.
It's to do with the different types of user object in jira. Try:
componentManager.getUserUtil().getUserByKey(lead)
This will give you an ApplicationUser, which is what the template expects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What change do I need if I want to apply this on the create form? Since there is not Issue Number?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you asking about behaviours or script fields? A new question is probably warranted judging by your deleted comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Currently I was able to apply it with behaviours but I wanted to do it on script fields (Just to know)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can't have a script field on the "create" form
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.