With the changes to JIRA api how do you get custom field in email template (script runner, workflow script))

Bart Woznicki December 16, 2015

This no longer works in JIRA :

<% out << 
issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("MySelect"))
 %>

So how would one get the custom field value using component accessor ?

This is for the email template inside the workflow with the script runner plugin.

Thank you.

3 answers

1 accepted

1 vote
Answer accepted
Bart Woznicki December 18, 2015

This is the actual way that works.

Thanks to @Tuncay Senturk [Snapbytes] you have pushed me in the right direction, however I fought there would be an easier way to achieve that.

 

<% def customFieldManager = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager() %>

<% def customField = customFieldManager.getCustomFieldObjectByName("MyField") %>

<% def field = customField.getValue(issue) %>

Output MyField : <% out << field %>
Alibek October 13, 2016

Thanks a lot!

0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 16, 2015
Here is getting field and field value
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject("customfield_11300")
// or 
// def customField = customFieldManager.getCustomFieldObjectByName("MySelect"))

def fieldValue = customField.getValue(issue);
0 votes
Vasiliy Zverev
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.
December 16, 2015

Try this:

issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MySelect"))
JamieA
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.
December 17, 2015

I think unfortunately you will need the FQCN, ie: com.atlassian.jira.component.ComponentAccessor

Vasiliy Zverev
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.
December 17, 2015

Agree.

Suggest an answer

Log in or Sign up to answer