Calculated value examples
This topic provides sample implementations of calculated values.
Scenario 1: Add a default value for a field
Goal: Set a new defect's status to "open".
Set a calculated value for the defect data type:
- In the defect data type, add a new data type rule.
- Click Calculated Value for master or target.
- Click Add Calculated Value.
- In the When section, click Add child criteria
.
-
Set the following values:
Field Value Operator "Is New" Set Field Select the defect's status field To value Select the status field's "open" value
Scenario 2: Assign items to parent nodes based on their source projects
Goal: Synchronize stories from two target projects (A and B) into a single master project (AA).
Stories from project A will be assigned to Node 1 in project AA, and stories in project B will be assigned to Node 2 in project AA.
Prerequisite: Create the Node 1 and Node 2 parent nodes in project AA.
A - AA mapping
For the A - AA mapping, define that the synchronization includes only items in project AA (master) that are under or include Node 1. For the example, the ID for Node 1 is 001.
- In the stories data type, add a new type rule, and click Sync Criteria (Master).
-
Define the following rules:
Field Value Operator Is Descendant Of Field Name (empty)
Field Value 001 Or
Field Value Operator Equals Field Name ID
Field Value 001 -
Using Calculated Values, define that all items from project A are synchronized into Node 1 in Project AA.
Click Calculated Values (Master), and create the following rule:
Field Value When Operator: Is New
And
Operator Field Name Is Empty parent Set field parent To value FindFirst(Story) From Operator Field Value Equals ID 001
B - AA mapping
For the project B - AA mapping, define synchronization criteria and calculated values as above.
Replace the ID value in project AA from with "002".
Scenario 3: Assign items to programs based on their source projects
Merge items from two projects into a third project under different programs.
Goal: Synchronize stories from two target projects (A and B) into one master project (AA). The stories' origin will be identified by a "program" field in project AA.
Prerequisite: Create the two programs in project AA. For example: ProgramA and ProgramB.
A - AA mapping
Define that the synchronization includes only items in project AA (master) that have the value ProgramA in the subproject field:
- In the stories data type, add a new type rule, and click Sync Criteria (Master).
-
Define the following rules:
Field Value Operator Equals Field Name subproject
Field Value ProgramA -
Using Calculated Values, define that items synced from target project A are associated with ProgramA in master project AA:
Click Calculated Values (Master), and create the following rule:
Field Value When Operator: Is New
Set field Subproject To value ProgramA From <leave empty>
B - AA mapping
For the project B - AA mapping, define synchronization criteria and calculated values as above.
Replace the program value in project AA with "ProgramB".
Scenario 4: Assign iterations to a release with similar start and end dates
Goal: Assign iterations to the release that has the closest start and end dates to the iteration's start and end dates.
This case assumes that releases do not have overlapping date ranges.
Data to synchronize: Synchronize both iterations and releases.
For your synchronization criteria, include in scope only iterations that have start and end dates:
- In the iterations data type, add a new type rule, and click, click Sync Criteria (Target).
-
Define the following criteria:
Field Value Operator Not Is Empty Field Name start date
And
Field Value Operator Not Is Empty Field Name end date
-
Click Calculated Values (Master), and define the following rule:
Field Value When Operator: Is New
Set field Release To value FindFirstOrThrow(Release) From Operator Field Value Less Than Or Equals Start date My->startDate And
Operator Field Value Greater Than Or Equals End date My->endDate
Scenario 5: Assign a story to a release
Goal: Assign a story to a release based on the release named in a field in the story.
Data to synchronize:
- Synchronize both stories and releases.
- Synchronize the field named "releaseName" whose value matches the name of a particular release.
Define a calculated value for the story data type:
Field | Value | ||||||
---|---|---|---|---|---|---|---|
When |
Operator: Is New |
||||||
Set field | Release | ||||||
To value | FindFirstOrThrow(Release) | ||||||
From |
|
Scenario 6: Assign a story to a release (cont.)
Goal: Assign a story to a release based on the release named in a field, without synchronizing the release field.
Data to synchronize:
- Synchronize both stories and releases.
- The field "releaseName" on the item the story is synchronized with matches the name of a release that has been synchronized.
Define a calculated value for the story date type:
Field | Value | ||||||
---|---|---|---|---|---|---|---|
When |
Operator: Is New |
||||||
Set field | Release | ||||||
To value | FindFirstOrThrow(Release) | ||||||
From |
|