November 17, 2015

TestTrack Calculated Fields: Common Questions and Solutions

Helix ALM
TestTrack calculated fields allow you to configure custom fields that automatically calculate numeric, text, date/time, pop-up item, and time span values based on other field values. In this blog post, I'm going to cover some common questions and solutions I hear from customers. See the help to learn more about custom fields and for additional examples.  If you're new to TestTrack calculated fields and ECMAScript formulas, you'll also want to review the Understanding calculated field formula syntax help topic. You may also want to review the following blog posts: This video also provides a great overview: Intro to Calculated Fields in TestTrack. The following examples cover common questions and solutions.  To use a solution, edit the formula to meet your needs then copy and paste it into the calculated custom field Formula area.

Example #1

I want to append event information to a calculated field, but I also want the field to retain the value from the last event.
var TicketCount = Item.Events.count("Update Ticket");
var ticketsStr = '';
for (ticketIndex = 1; ticketIndex < TicketCount; ticketIndex++)
	ticketsStr = ticketsStr +, "Update Ticket").fieldValue("Customer Name") + " [" +, "Update Ticket").fieldValue("Ticket Number") + "] ";

result = ticketsStr;

Example #2

I have two workflow events. I want to take the date value from the event that exists (only one will exist in this example) and enter it into the calculated custom field.
var result = 0;

var CloseNotbugdate = Item.Events.count("Close - Not a bug ") > 0 ? Item.Events.last("Close - Not a bug ") : undefined;

var Closebugdate = Item.Events.count("Move to RnD ") > 0 ? Item.Events.last("Move to RnD ") : undefined;

if ((CloseNotbugdate!== undefined)&& (CloseNotbugdate.fieldValue("Date") !== undefined)){
result = CloseNotbugdate.fieldValue("Date");
} elseif (Closebugdate!=- undefined) {
result = Closebugdate.fieldValue("Date");

Example #3

I want to calculate how much time a defect was in a specific state. There are two different events that must be entered first.
var result = 0;

if ((Item.Events.count("Fix") &gt; 0) && (Item.Events.count("Release to Testing") &gt; 0))
var fixDate = Item.Events.last("Fix").fieldValue("Date");
var releaseDate = Item.Events.last("Release to Testing").fieldValue("Date");

if ((fixDate !== undefined)&& (releaseDate!== undefined))
result = (releaseDate - fixDate) / 60000.0 ; // convert to minuteselse
result = 0;
} else {
result = 0;

Example #4

I would like to calculate a Prioritization Score based on a combination of values entered in other custom fields. The Prioritization Score value is based on 4 custom fields that each count for a portion out of a 100.
( Item.fieldValue("Strategic Alignment (25)") * 2.5 ) +

( Item.fieldValue("Market Attractiveness (35)") * 3.5) +

( Item.fieldValue("Technical Feasibility (15)") * 1.5) +

( Item.fieldValue("Increase Revenue (25)") * 2.5 )

Example #5

I created a calculated field named TestTime-Open to display the difference between the current time and the StartedTesting event. I created another calculated field named TestTime-Closed, which displays the difference between the FinishedTesting event and the StartedTesting event. The Testing-Open field continues to get larger once testing is finished. I would like a single field, called TestTime, that checks the FinishedTesting event (or closed state). If that state is still open, the field should use the current time; otherwise, it should use the FinishedTesting event. The simplest way is to use the ECMAScript exception handling so, if you access a field and it doesn’t exist, an exception is thrown. The following example outputs the time in testing in seconds.
var testEnd = 0.0;
var testStart = 0.0;

try {
testStart = Item.Events.last("StartedTesting").fieldValue("Date");
try {
testEnd = Item.Events.last("FinishedTesting").fieldValue("Date");
} catch(err) {
testEnd =;
} catch(err) {
testStart = 0;
Image courtesy of Renjith Krishman at