Calculated text field example

Calculated text fields can concatenate text strings or return text values.

The following example shows the configuration for a calculated field that analyzes requirement status and groups them into a smaller set of categories, which can be useful when reporting on requirements that are drafts, in progress, or complete.

The following formula returns the status category name. Comments are included to explain each line of the formula.

// variables for the return value and requirement status

var category = "";

var status = "";

// retrieve workflow status as a string

status = Item.fieldValue("Status").toString();

// status included in Draft category

if (status.match("Draft"))

category = "Draft";

// statuses included in Done category

else if (status.match("Implemented"))

category = "Done";

else if (status.match("Obsolete"))

category = "Done";

// all other statuses are included in In Progress category

else

category = "In Progress";

// returns the category

category;