Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Velocity: Email template subject for batching notification problems

Fabian
Contributor
January 22, 2026

Hello,

i have a big problem. I need to change the email template in jira datacenter.

What i need is, that on every mail the mail subject should include a custom field value.

This solution works for the mail templates without batching notification:

issueupdate.vm

#set($customFieldManager = $componentManager.getCustomFieldManager())
#set($serialnumberField = $customFieldManager.getCustomFieldObject("customfield_10xxx"))
#set($serialnumber = $issue.getCustomFieldValue($serialnumberField ))

#if ($serialnumber)
  ($issue.key) [$serialnumber] $issue.summary
#else
  ($issue.key) $issue.summary
#end
Now i tried to implement it for the batchting notification file:
issueUpdateBatcher-subject.vm
#set($customFieldManager = $componentManager.getCustomFieldManager())
#set($serialnumberField = $customFieldManager.getCustomFieldObject("customfield_10xxx"))
#set($serialnumber = $issue.getCustomFieldValue($serialnumberField ))

#if ($serialnumber)
    #set($headersum = "[$serialnumber] " + "$header.issueSummary" + " with SNR")
    $i18n.getText('issue.update.batch.mail.subject', [$header.issueKey, $headersum])
#else
    #set($withoutSN = "$header.issueSummary" + " wihtout SNR")
    $i18n.getText('issue.update.batch.mail.subject', [$header.issueKey, $withoutSN ])

#end

The var serialnumber is always empty / null and i have no clue how to solve that issue.

I hope you can help me.

 

Thx

1 answer

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
January 28, 2026

Hi @Fabian 

As far as I remember in batched notifications, it is not rendered with an $issue in the velocity context. So it always returns null. You will need to fetch the issue and get the customfield value from the issue which may not be the most performant way.

I am not 100% sure but I think you can get the issuekey from the $header (it is best to check it out) and the code will be like the below

#set($customFieldManager = $componentManager.getCustomFieldManager())
#set($issueManager = $componentManager.getIssueManager())

#set($serialnumberField = $customFieldManager.getCustomFieldObject("customfield_10xxx"))
#set($theIssue = $issueManager.getIssueObject($header.issueKey))
#set($serialnumber = $theIssue.getCustomFieldValue($serialnumberField))

... the rest of your code

Suggest an answer

Log in or Sign up to answer