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:

($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

0 votes
Accepted answer

@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")

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.


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(""):</th> <td> #if ($changelogauthor) #authorlinkkey($changelogauthor.key $linkstyle) #elseif ($ #emailHistoryMetadataParticipant($, 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 Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,647 views 18 21
Read article

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