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
#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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.