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?
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))}
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")) %>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.