Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Very often (60% of all use-cases to be precise) you want to receive a notification when

  • Status is changed from A to B
  • Issue priority is changed from A to B
  • Another Issue standard or custom field is changed from A to B

 

With Raley notifications you can receive this notifications, it just requires some configuring. Your starting point is to create a new messenger with

JIRA Event:    issue updated

JQL rule:       project = YOUR_PROJECT_KEY

The second condition is not mandatory, but highly recommended to keep things under control in scope of a single project.

 

Now we need to create a message template that will notify your user about the change in XXX. Remember the "most important rule" in Raley notifications:

If message template evaluates to empty then no message will be sent out


This is exactly what we need to make sure that messages will be sent only when they match predefined condition in our template, but how do we write a condition properly, so that it will be non empty when the respective field is changed and empty for all other issue updated events? As usually, picture is better than thousands of words, so here you go:

Image Added


There are two sections of Issue fields code. In the top we describe a condition by checking first if $issue.last_change field exist. If so, we're iterating all $issue.last_change.items that were changed. And if the $item.field equals to "Status" then we render the message. Here's the source code for you convenience.

Code Block
#foreach ($issue in $issues)
    #if ($issue.last_change)
         #foreach ($item in $issue.last_change.items) 
             #if ($item.field == "Status")
 
                 Here comes the message that renders only when Status is changed
 
             #end 
         #end 
    #end 
#end 


So far, so good, but let's say you need to track the Status change from "In Progress" to "Done". For that, we need to track two variables "fromString" and "toString" like in the following example:

Code Block
#foreach ($issue in $issues)
    #if ($issue.last_change)
         #foreach ($item in $issue.last_change.items) 
             #if ($item.field == "Status" and $item.fromString == "In Progress" and $item.toString == "Done")
                  Here comes the message that renders only when Status is changed from In Progress to Done
             #end
         #end
    #end
#end


As you can see from the examples above, it all boils down to checking value of $item.field and optionally $item.fromString and $item.toString if you need more fine-grained control. But how would you know precise value of $item.field to compare against? There's a simple way to do that. Just change the field you're interested in in your testing issue and open that issue in Raley Notifications fields navigator as shown below:


Image Added

Expand issues->issue->changelog->histories (first item) -> items -> item and you'll see there the name of your field that you've just changed, it's original value and new value.