Displays the lead for the component selected for this issue, making use of the User display template.

Script is:

package com.onresolve.jira.groovy.test.scriptfields.scripts

def components = issue.componentObjects.toList()
if (components) {
    return components?.first()?.componentLead
}

We return a User object, and use the User Picker template so the user is displayed with a clickable link and mouseover popup etc.

Make sure you return an ApplicationUser object and not a User. If you do the latter the template will show Anonymous.

Template

User Picker (single user)

Searcher

User Picker Searcher

Show Multiple Users

To show all unique component leads you would use this script:

package com.onresolve.jira.groovy.test.scriptfields.scripts

def componentLeads = issue.componentObjects*.componentLead.unique()
componentLeads.removeAll([null])
componentLeads

Template

User Picker (multiple users)

Searcher

Multi User Picker Searcher

This will look like:

showComponentLeads
Don’t forget to reindex if you want your newly created scripted custom field to show up in existing issues.

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.