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?
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.