Question: How to trigger a email when value of custom field is updated?
Answer: Create a notification as shown in the screenshot below:
Add message template similar to the example below:
#foreach ($item in $issue.lastchange.items) #if ($item.fieldId == "CAB" and $item.fromString == "value before" and $item.toString == "value after") <pre> Hi there, User $issue.lastchange.author.displayName has made some changes to <a href="https://yourjirainstance.atlassian.net/browse/$issue.key">$issue.key</a>: <table border="1"> <tr> <th><b>Field</b></th> <th><b>Old value</b></th> <th><b>New value</b></th> </tr> #foreach ($item in $issue.lastchange.items) <tr> <td>$!item.field</td> <td>$!item.fromString</td> <td>$!item.toString</td> </tr> #end </table> Best, Raley </pre> #end #end
Make a note of the code in line 2 : it shows how to check the customfield value against before and after.
But how do I know what value should I check against?
It is sometimes not obvious what kind of values you should be comparing $item.fromString and $item.toString against. Fortunately, there's a simple way to figure it out.
1) Create a Jira ticket and perform changes that you want to track in your notification.
2) Create a new notification and in Template window paste this value $issue.lastchange.items Then input the issue key that you just created and click on Preview. You'll see something like this in the message preview:
As you see, during the last change several fields were updated: Component, Customs select, Custom cb group and duedate. For each of the fields changed you see the before value in fromString and after value in toString. Use those values in your Velocity #if condition.