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:

  1. In the defect data type, add a new data type rule.
  2. Click Calculated Value for master or target.
  3. Click Add Calculated Value.
  4. In the When section, click Add child criteria .
  5. 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

Back to top

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.

  1. In the stories data type, add a new type rule, and click Sync Criteria (Master).
  2. 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
  3. 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".

Back to top

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:

  1. In the stories data type, add a new type rule, and click Sync Criteria (Master).
  2. Define the following rules:

    Field Value
    Operator Equals
    Field Name

    subproject

    Field Value ProgramA
  3. 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".

Back to top

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:

  1. In the iterations data type, add a new type rule, and click, click Sync Criteria (Target).
  2. 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

  3. 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

Back to top

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:

  1. Synchronize both stories and releases.
  2. 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
Operator Field Value
Equals name My->releaseName

Back to top

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:

  1. Synchronize both stories and releases.
  2. 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
Operator Field Value
Equals name My->Other->releaseName

Back to top