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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

66 views 0 5
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