Add a custom label to a event notification email

I'm trying to add a custom label field to the subject line of workflow transition event emails.  I've created a new email template for this and it's successfully sending me emails unfortunatly I can't get the custom label values to show up.  The code for the subject line is:

#disable_html_escaping()
#set($cFieldValue=$issue.customFieldManager.getCustomFieldObject("customfield_10064"))
($issue.key) $issue.summary - $issue.getCustomFieldValue($cField).getValue()

When I get the email I get this in the subject line: 

JIRA DB (LER-7) Test - $issue.getCustomFieldValue($cField)

I've tried several other methods that I've found to try and get the fields value with no luck.  How do I get JIRA to send the value instead of this?  

1 answer

1 accepted

@Theodore Adams -

JIRA Version?

Did you follow (roughly at least) the instructions on this page?

I haven't played with labels much (yet) so I don't know if there are tricks to retrieve and set them, but here's the code from that page where they are setting a custom field and referencing it in the notification:

#if ($issue.getCustomFieldValue("customfield_10000"))
$stringUtils.leftPad($issue.getCustomField("customfield_10000").name, $padSize): $issue.getCustomFieldValue("customfield_10000")
#end

From what I've seen you typically get the variable reference (what you are currently seeing) instead of the variable value when the routine is returning NULL. I'd first modify your notification template hard-coding in a returned value OR just check the returned value for null and return a different string instead.

-wc

Apparently I was being an idiot yesterday, the issue I was testing with didn't have that custom filed populated. Once I did it worked. I've added the logic you suggested to check to see if it has a value. Got it working now. I do have another question though. I'm trying to add the same field to the body of the email. I'm editing changelog.vm and added a section to the bottom. For some reason I can't seem to get the field name to bold like the rest of the items in the email. Code is below: #* @vtlvariable name="changelog" type="org.ofbiz.core.entity.GenericValue" *# #disable_html_escaping() #if ($changelog) <table class="keyvalue-table"> #if ($worklog) #parse('templates/email/html/includes/patterns/worklog-row.vm') #end <tr> <th>#text("template.change.by"):</th> <td> #if ($changelogauthor) #authorlinkkey($changelogauthor.key $linkstyle) #elseif ($changelogmetadata.actor) #emailHistoryMetadataParticipant($changelogmetadata.actor, true) #else #text("common.words.anonymous") #end </td> </tr> #foreach ($changeitem in $changelog.getRelated("ChildChangeItem")) #if ($changeitem.getString("field").equals("description")) #set ($changelogItemIssueDescription = $changeitem) #end #if(!$changeitem.getString("field").equals("WorklogTimeSpent") && !$changeitem.getString("field").equals("WorklogId") && !$changeitem.getString("field").equals("description")) <tr> <th>$textutils.htmlEncode($velocityhelper.getFieldName($changeitem, $i18n)):</th> <td> #if ($changeitem.getString("field") == "Comment") #set ($oldstringKey = "oldvalue") #set ($newstringKey = "newvalue") #else #set ($oldstringKey = "oldstring") #set ($newstringKey = "newstring") #end #set ($oldText = "") #set ($newText = "") #set ($oldText = $velocityhelper.getPrettyFieldString($changeitem.getString("field"), $changeitem.getString($oldstringKey), $i18n, "")) #set ($newText = $velocityhelper.getPrettyFieldString($changeitem.getString("field"), $changeitem.getString($newstringKey), $i18n, "")) $!diffutils.diff($oldText, "background-color:${auiErrorBackgroundColour};text-decoration:line-through;", $newText, "background-color:${auiSuccessBackgroundColour};") </td> </tr> #end #end #if ($issue.getCustomFieldValue("customfield_10064")) <tr> <th>$textutils.htmlEncode($issue.getCustomFieldObject("customfield_10064").name):</th> <td> $issue.getCustomFieldValue("customfield_10064") </td> </tr> #end </table> #end Any idea why the <th> tag doesn't seem to be working?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot