Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Email template - custom field value not found

Mladen Andzic January 26, 2015

Hello,

I've changed email template for issue Created event by adding value from custom field named ITDR, like this:

 $issue.getCustomFieldValue("ITDR")

As a result in notification email I get the same text (script code) instead of custom field value from specific issue.

Even in TemplateSet preview using existing issue it looks the same.

Of course I doublechecked that custom field exists for specific issue and it is populated.

What I am doing wrong?

JIRA version is 6.3.6

Thanks.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Paul Pasler
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 26, 2015

Ah ok, so you have to do it the way [~ferenc kiss] suggested and use the customfield-Id.
This is the official document: https://developer.atlassian.com/display/JIRADEV/Adding+Custom+Fields+to+Email

$issue.getCustomFieldValue("customfield_11208")

You find the customfield-id by browsing Administration > Issues > Custom Fields (see the screenshot)customfield_id.png

Mladen Andzic January 26, 2015

Thank you Paul, it works now! The way how to find customfield_id is new to me, I am a little bit surprised it is not visible at Administration > Issues > Custom Fields without code inspector.

2 votes
Midori
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.
January 26, 2015

You have to identity the custom fields with their ID's, not with their names:

$issue.getCustomFieldValue("customfield_10123")

...where 10123 is the numerical identifier of your CF.

Mladen Andzic January 26, 2015

Thank you Ferenc, it works now! Honestly, somehow I was convinced that ID of CF is the same as its name, maybe because ID isn't visible at CF admin screen.

0 votes
Paul Pasler
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 26, 2015

You can't acces the value directly with the name. First you have to access the CustomField (See the API: https://docs.atlassian.com/jira/6.3.6/com/atlassian/jira/issue/Issue.html).

Use the CustomFieldManager for accesing the CustomField.

Something like this should do what you want:

CustomField field = customFieldManager().getCustomFieldObjectByName("ITDR")
// You can cast if you know the data type 
Object itdr = issue.getCustomFieldValue(field);
Mladen Andzic January 26, 2015

Hello Paul,

thank you for quick answer.

I am using Velocity, like it was explained in this question.

 

TAGS
AUG Leaders

Atlassian Community Events