Forums

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

Custom Field value in Email Subject

Darin Hafer
Contributor
April 11, 2019

I have Jira Server 7.9.2.

 

I'd like to include a custom field value in the Email subject sent from a Post-Function.

 

I've read this article but the suggestions don't work -  - https://community.atlassian.com/t5/Answers-Developer-Questions/Send-email-with-custom-field-in-subject-line/qaq-p/498972

 

Here's what I tried

1) Try this in my Subject:

Custom field value: $issue.getCustomFieldValue('customfield_12602')

Doesn't work in Preview. Preview says:

groovy.lang.MissingPropertyException: No such property: getCustomFieldValue for class: com.atlassian.jira.issue.IssueImpl

 

2) Also try this in my Subject:

Custom field value: <% out << $issue.getCustomFieldValue('customfield_12602') %>

This yields:

groovy.lang.MissingPropertyException: No such property: $issue for class: groovy.lang.Binding

 

3) Here we go

Custom field value: <% out << issue.getCustomFieldValue('customfield_12602') %>

This yields a different result....

groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() is applicable for argument types: (java.lang.String) values: [customfield_12602] Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object)

 

I understand this one. I need to get the customFieldObject first, then provide that as an argument to getCustomFieldValue.

How can I make extra calls in the subject to get that CustomField BEFORE I get it's value? Can I do all that in a Subject template?

1 answer

1 accepted

3 votes
Answer accepted
Ivan Tovbin
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 12, 2019

Hi Darin,

If you are using a ScriptRunner postfunction to send a custom email, then something like this should do the trick:

Custom field value: ${issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObject((Long) 12602))}
Darin Hafer
Contributor
April 12, 2019

Genius! Thank you very much @Ivan Tovbin . That worked beautifully. 

 

I forgot to mention the 4th option I tried. It was a derivative of what you suggested, but didn't work:

<% out << issue.getCustomFieldValue(com.atlassian.jira.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Field Name")) %>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events