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.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

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

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.