May 8, 2013

How to Trigger on Event Date Change in TestTrack

Helix ALM
Many workflows in TestTrack have events that track a particular date, such as a due date or completion date. The event can occur multiple times, and it’s easy to create an automation rule to let someone know that the event has re-occurred, but what if you wish to notify someone only when a date  has changed? A custom calculated field can be created as a flag using a simple formula that first finds the event count, and if the event has happened at least once compares the most recent event with the event that occurred just before that. This flag can then be used in automation rules to move items through the workflow or notify users.  The output type for this field is numeric (no decimal places) as it will only have the value of 0 or 1. Since the field will only be accessed by automation rules you will want to modify the Security groups to hide the field for both Add and Edit actions. Once you have created the field create a filter that restricts the value of the custom field to “1”. Then, use that filter in an automation rule with the trigger based on the event being added to the item. For example, a rule  to notify the assigned users via email that a critical defect date has changed would look like this:
[Notify on Date Change] applies to [defects] passing filter [Date Changed] -- when [Estimate event is added]
Send email using template [Defect Changed] to [all assigned users]
The formula below can be copied and pasted directly in the formula field.  Modify the event and field name as needed.
//has Completion Date changed?
var x=Item.Events.count("Estimate");
var chg;
//no events so set to 0
if (x==0)
//first event means date has changed
if (x==1)
//multiple events
if (x>1)
    //get previous event index (index is 0-based, last event is x-1, the event before that is x-2)
    x=x-2;,"Estimate").fieldValue("Completion Date")
    date2=Item.Events.last("Estimate").fieldValue("Completion Date")
    //if the last date is equal to the previous date then it has not changed (0)
    if ((date2-date1) == 0)
        //else it has changed (1)
//return the current value of chg