You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm trying to add a custom field value to the create issue HTML email template, but stumbling. The field is required, so there will always be a value present on issue creation.
Attempt 1:
I've followed the directions here: https://developer.atlassian.com/server/jira/platform/adding-custom-fields-to-email/?_ga=2.56485292.608403254.1563807890-1574526416.1556543036
When I add the customerfield.vm as indicated below
#disable_html_escaping() #set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707")) #if($issue.getCustomFieldValue($customfield)) <tr> <th>#text($customfield.name):</th> <td class="has-icon"> $textutils.htmlEncode($issue.getCustomFieldValue($customfield), false) </td> </tr> #end
Instead of the comma separated values of the field, I get this message: $textutils.htmlEncode($issue.getCustomFieldValue($customfield), false)
Attempt 2:
I tried the suggestion in another article, but instead of the value, I get the label name a second time.
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#set ($customfieldvalue = $customfield.getValue($issue))
#if($customfieldvalue)
<tr>
<th>#text($customfield.name):</th>
<th>$customfield</th>
</tr>
#end
and tried
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#set ($customfieldvalue = $customfield.getValue($issue))
#if($customfieldvalue)
<tr>
<th>#text($customfield.name):</th>
<th>$customfieldvalue</th>
</tr>
#end
I can't tell if my issue is coming from the createissue.vm or customfield.vm or how to fix it. any help/suggestions would be very much appreciated!
Hello @Christina Hiller do you create the customfield.vm and add this to the event createissue.vm?
please attach both files..
I'm having trouble attaching the files themselves, but here's the content.
createissue.vm
#disable_html_escaping()
#defaultMailHeader("email.event.activity.created.issue", $issue.reporter)
#set ($issueTitleBody="#parse('templates/email/html/includes/patterns/issue-title.vm')")
#rowWrapperNormal($issueTitleBody)
#rowWrapperNormalBegin('' 'wrapper-special-margin')
<table class="keyvalue-table">
#parse("templates/email/html/includes/fields/issuetype.vm")
#parse("templates/email/html/includes/fields/affectsversions.vm")
#parse("templates/email/html/includes/fields/assignee.vm")
#parse("templates/email/html/includes/fields/attachments.vm")
#parse("templates/email/html/includes/fields/components.vm")
#parse("templates/email/html/includes/fields/createddate.vm")
#parse("templates/email/html/includes/fields/duedate.vm")
#parse("templates/email/html/includes/fields/environment.vm")
#parse("templates/email/html/includes/fields/fixversions.vm")
#parse("templates/email/html/includes/fields/labels.vm")
#parse("templates/email/html/includes/fields/priority.vm")
#parse("templates/email/html/includes/fields/reporter.vm")
#parse("templates/email/html/includes/fields/securitylevel.vm")
#parse("templates/email/html/includes/fields/timetracking.vm") #parse("templates/email/html/includes/fields/customfield.vm")
</table>
</br>
#rowWrapperNormalEnd()
#if ($issue.description)
#set($textParagraph = $issue.htmlDescription)
#rowWrapperNormal("#parse('templates/email/html/includes/patterns/text-paragraph.vm')", '', 'issue-description-container')
#end
#set ($commentActionBody="#parse('templates/email/html/includes/patterns/comment-action.vm')")
#rowWrapperNormal($commentActionBody)
#parse("templates/email/html/includes/footer.vm")
latest customfield.vm
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#set ($customfieldvalue = $customfield.getValue($issue))
#if($customfieldvalue)
<tr>
<th>#text($customfield.name):</th>
<th>$customfieldvalue</th>
</tr>
#end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try with this
customfield.vm
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#if($issue.getCustomFieldValue($customfield))
<tr>
<th>#text($customfield.name):</th>
<td class="has-icon">
$textutils.htmlEncode($issue.getCustomFieldValue($customfield), false)
</td>
</tr>
#end
don´t forget restart jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manuel
Using the code provided, above screen is what comes through.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another question I have is if I expect that multiple values are expected in the custom field results, would that result in an error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I replaced the customfield.vm file with the following and it worked.
#disable_html_escaping()
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_15707"))
#if($issue.getCustomFieldValue($customfield))
<tr>
<th>#text($customfield.name):</th>
<td class="has-icon">
$customFieldManager.getCustomFieldObject("customfield_15707").getValue($issue)
</td>
</tr>
#end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i was already trying :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.