Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,297,589
Community Members
 
Community Events
165
Community Groups

How to retrieve multiuser field values in scriptrunner send custom email

Edited

Hi All,

I am trying to send a custom email using "Scriptrunner send custom email" template where I am retrieving values of some issue fields. I am able to it successfully for summary, description etc but not able to understand how I can do it for multi user field "Implementer". The code that I used below extracts the Username(id) rather than the Full Display name. Rest of other fields are working as expected.

When I use .getDisplayName() method it errors out. Could you suggest a solution for it?

 

The following Change request has been approved (Issue $issue).

Summary:
$issue.summary

Description:
$issue.description

Approved Window Start:
<% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approved Window Start")) %>

Approved Window End:
<% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approved  Window End")) %>

Change Implementer:
<% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Implementer")).getDisplayName() %>

2 answers

1 accepted

Hi @Veda Bhat,

I hope this solve your issue:

Change the last line as following:

<% out << ((issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Implementer")) as List<com.atlassian.jira.user.ApplicationUser>).collect { it.displayName }) %>

 

This worked! Thank you so much!!

Hi @Veda Bhat,

you should change the last line as following:

<% out << (issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Implementer")) as com.atlassian.jira.user.ApplicationUser).getDisplayName() %>

Thank you for you response! I tried modifying the last line as you mentioned above and got below error:

java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMail(AbstractSendCustomEmail.groovy:240)
at java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMail(AbstractSendCustomEmail.groovy:240)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.super$4$constructMail(SendCustomEmail.groovy)

Hi @Veda Bhat,

your issue could be in the condition or in other sections of your ScriptRunner send custom mail. Please, could you report the configuration?

 

Hi @Andrea Pannitti

I do not have anything specified under Condition and Configuration section of "Scriptrunner Send custom email". The reason is I have added this as a post function to a transition in a workflow. Whenever this transition happens it should send this email to a distro list .

All other fields are retrieving accurate values as you can see in result window below except this one multi user field called " Implementer" which retrieves user names as id instead of full name:

 

result.PNG

send custom email template.PNG

Hi @Veda Bhat,

the problem was due to the fact that your custom field Implementer is a multi-user and not a single-user custom field. So, to solve the issue, look my last answer.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,763 views 37 47
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you