JIRA 4.3 : Adding Custom Fields to Email
This page last changed on May 18, 2010 by jlargman.
Printing a custom field in a JIRA email is fairly easy in 3.6 and above. The feature request to integrate this into JIRA is being tracked at JRA-4619. Step 1: find the custom field IdThis can be discovered from the database, or by examining the URLs of custom field pages. For example, here the id of the custom field is 10000: Step 2: edit the velocity template
Locate the Velocity template of the email type you wish to modify. For instance, you may want to modify the 'issue created' template, as well as the template reused in 'issue commented': atlassian-jira/WEB-INF/classes/templates/email/text/issuecreated.vm Add the following snippet where you want it to appear in the file: #if ($issue.getCustomFieldValue("customfield_10000")) $stringUtils.leftPad($issue.getCustomField("customfield_10000").name, $padSize): $issue.getCustomFieldValue("customfield_10000") #end
In atlassian-jira/WEB-INF/classes/templates/email/text/includes/issuesummary.vm you will want: #if ($issue.getCustomFieldValue("customfield_10000")) >$stringUtils.leftPad($issue.getCustomField("customfield_10000").name, $padSize): $issue.getCustomFieldValue("customfield_10000") #end Note: you need to change the custom field id to the id observed in step 1. Here it is 10000 - yours will probably be different. If you wish to iterate over all related custom fields you can use the following example: #foreach ($value in $customFieldManager.getCustomFieldObjects($issue)) >$stringUtils.leftPad($value.getName(), $padSize): $!value.getValueFromIssue($issue) #end Restart JIRA.To make the changes take effect, restart JIRA. If you wish to avoid the continual restarts during testing, edit atlassian-jira/WEB-INF/classes/velocity.properties and alter this section as the comment says: # To enable autoreloading, set cache to false and uncomment the autoreload line class.resource.loader.cache=true #velocimacro.library.autoreload=true |
![]() |
Document generated by Confluence on Mar 27, 2011 18:54 |