If you completed our previous chapters then you should already know how to display data in Raley using templates. But often you will want to choose which pieces of information will be shown and when. This is especially important because 

Raley Notifications wouldn't sent message if rendered template evaluates in empty string


We stated it once in the HelloWorld example and will say it again here. This is very important because if you want to prevent Jirassimo from sending a message you must make sure that the template will evaluate to non-empty string only when you need the message. Otherwise, it should remain empty. JQL won't always help you with that, so it means that we have to get our hands dirty with the code.

Here's the first example 

I need to receive messages when the status of the issue is changed from Open to In Progress

Your first thought would be to use JQL of this kind together with the event "issue updated":

project = ABC and status CHANGED FROM "To Do" TO "In Progress"

Fine? Almost, except for a small detail - once the issue has gone from To Do to In Progress, you'll receive a new notification every time this issue is updated. This is because formally IT WAS once changed from To Do to In Progress and the JQL will match. But you need to get the message only when the update actually changes its status. How would you do that?

Have a look at our reference JIRA issue. In the third row you'll notice a field called last_change. This is a convenience field that actually keeps the last element from changelog and as its name implies it keeps the information about the most recent changes to the to issue. To catch transition To Do ->  In Progress  we could write:

 

#foreach ($issue in $issues)
  #foreach ($item in $issue.lastchange.items)
    #if ($item.fromString == "To Do" && $item.toString == "In Progress")
        Issue $issue.key status is chagned to In Progress
    #end
  #end
#end

 

Note, that in line 2 we refer to last_change as $issue.lastchange (without the underscore). This is exception and, normally, to refer other fields you need to use JavaBean conventions of camelCaseProperty

Using our reference JIRA issue we'll get this text:

Issue JAD-4 status is chagned to In Progress