Add custom field to email template

Rob B
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.
April 5, 2019

Im trying to add a custom field into a script runner email template.

Dear ${issue.assignee?.displayName},

Value = $
issue.getCustomFieldValue("Partner")

Regards
${issue.reporter?.displayName}

 Reporter and assignee works fine but the custom field throws error out.

Thanks

1 answer

0 votes
Payne
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.
April 5, 2019

Try something like this.

def partnerField = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Partner")
def partner = issue.getCustomFieldValue(partnerField)?.toString() ?: ""

You can either include that code inside a <% ... %> block at the top of the Email Template field, or you can include it in the Condition and Configuration section, and then assign the value to a config variable that you can then reference in the template, e.g.

config.partner = partner

 Then you can reference $partner in the template.

Suggest an answer

Log in or Sign up to answer