Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a user's full name from the approvers list?

Bruce Reed
Contributor
December 13, 2018

We use a scriptrunner post function to sends email regarding approvers of an issue. I need to grab the persons name from the approvers custom field. We are getting the approvers list using the following code:

def approversCF = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find {it.name == "Approvers"}
def approvers = issue.getCustomFieldValue(approversCF)

This returns a list user names in the format:

[ joe.user@somedomain.com(joe.user@somedomain.com)]

Our user names are email addresses, so it looks like it returns both the username and the email address. What's the best way to get the user's full name from the above?

 

1 answer

1 accepted

1 vote
Answer accepted
Carmen Creswell [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2018

Hi Bruce, 

Here is a slightly modified version of your code that works for me: 

import com.atlassian.jira.component.ComponentAccessor

def cfManager = ComponentAccessor.getCustomFieldManager()
def approversCF = cfManager.getCustomFieldObjectsByName("Approvers")[0].getValue(issue)
def approversName = approversCF.displayName

The variable approversName holds the full names. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events