Add Custom Field Value to Email Template

Antoine
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.
September 15, 2016

Hello all, how could i put a custom field value to an existing email template ?

1 answer

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 15, 2016
Antoine
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.
September 20, 2016

I do not manage to integrate my field, you know how can it be done?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2016

Yes, it's covered in the document I pointed to.

Antoine
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.
September 20, 2016

It is not very clear, I have to modify only issuecreated.vm in the folder " text " or in all the folders?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2016

I'm not sure what is unclear in those docs.  You have to find every file that generates part of the body of an email where you want to include the field and add the required code for your field to it.

Antoine
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.
September 20, 2016

I have id of my fields custom. I added the code datum in doc ("

https://developer.atlassian.com/jiradev/jira-platform/jira-architecture/jira-templates-and-jsps / adding-custom-fields-to-email ") but it doesn't work...

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2016

I'm afraid "it doesn't work" tells us nothing about what might have gone wrong.

Antoine
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.
September 21, 2016

I can nothing tell you except that what I have make by following the documentation does not show the deliberate custom field.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2016

If you've followed the docs, then the field will be there in the email.  So, trace through what you are doing in full - which files, what type of email, was the field filled etc.  Try some basic debugging - try sticking plain text in the template - does that come out?

Antoine
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.
September 21, 2016

The id of my field is 10007 so i've add "

#if ($issue.getCustomFieldValue("customfield_10007"))

$stringUtils.leftPad($issue.getCustomField("customfield_10007").name, $padSize): $issue.getCustomFieldValue("customfield_10007")

#end " in /template/email/text/issuecreated.vm.

 

I've changed the values in velocity.properties to not have to restart JIRA.

Then when i create a new issue, there is no custom fields in the mail template..

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2016

Ok, that looks good. Some more debugging (apologies if some of these seem obvious, but if I don't ask the full set, we might miss something)

  • When you create the issue, do you fill in field 10007 with any data?
  • When you altered the properties file, did you restart JIRA?
  • I'm not 100% sure that the velocity caching applies to the mail templates, so you might want to restart anyway.
  • I assume you're getting the mail with no extra fields, but are you getting the right type?  Is your profile set to get plain text email?
  • What happens if you add plain text to the template?  Just above or below your #if #code #end block, could you add something obvious like "I need to know if this hack comes out" in just plain text, no punctuation or attempts at formatting.

 

Antoine
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.
September 21, 2016

Yes the field 10007 is filled with data.

Oh ok, i'll restart.

What do you mean by "get plain text email" ?

I restarted the instance, I added a sentence in the file but it does not display on the e-mail.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2016

Your profile has a setting for getting emails in plain text or html.  Make sure yours is set to text

Antoine
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.
September 21, 2016

I received the mail with the sentence inside.

 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2016

Ah, good, so you were editing the plain text templates, and receiving html emails?

Suggest an answer

Log in or Sign up to answer