Define calculated values
Calculated Values are field values that will be automatically set during synchronization if certain conditions are met. For example, you can define a rule that, when the connection creates a new story, its Tested value will be set to "false”.
Add a calculated value
You add a calculated value in the Connection Rules window.
To add a calculated value:
- In the Connection Rules window, choose a type and click Add Type Rule.
- In the Connection Type Rule dialog box, select the Calculated Values tab for either the Target or Master.
Click the Add Calculated Value button. The Add Calculated Value window opens:
Specify the When query. The When query determines the condition that an asset must meet in order for the calculated value to be applied. For details on specifying the When query, see Build a query.
Note: If you do not specify a When query, then the Calculated Value will always be applied when an asset is synchronized.
In the Set Field dropdown, choose the field whose value you want to set.
In the To Value field, specify the value that you want to assign to the field. Use one of the following options:
- Type a static value ("123"), or choose a value from the dropdown list ("Open").
- For reference fields, you can set the value using one of the "Find" functions. The "Find" function will discover the item according to the criteria you specify. Enter a function and define a From query. For a list of available functions, see Functions.
If you entered a function in the To Value field, define a From query. For details on specifying the From query, see Build a query.
Click OK to save.
Assume you want the stories synced into a Jira project to all be assigned to a purpose-created parent story. The calculated value form will look like this:
|Operator: "Is New"|
|Set Field: "Parent"||To value: "FindFirst(Story)"|
|Operator: "Equals"||Field: "ID"||Value: "1923"|
The value can be a fixed value ("123", "TRUE", or "Open"), a reference to another field in the same item (i.e. My->name), a reference to a field on the "other" side (i.e. Other->name), or a function that operates on an list of items of a given type.
For examples of synchronization scenarios that you can implement with calculated values, see Calculated value examples.
|Max(type, property)||The largest of a set.|
|Min(type, property)||The smallest of a set.|
|FindFirst(type)||The first in a set that satisfies the find criteria.|
|FindAll(type)||Returns all in a set that satisfy the find criteria.|
|FindFirstOrThrow(type)||The first in a set that satisfies the find criteria. Returns an error if not found.|
|FindAllOrThrow(type)||Returns all in a set that satisfy the find criteria. Returns an error if not found.|
|FindFirstInProperty(syncItemProperty)||The first in a set that satisfies the find criteria, looking only at the SyncItems in the given property.|
|FindAllInProperty(syncItemProperty)||Returns all in a set that satisfy the find criteria, looking only at the SyncItems in the given property.|
|FindFirstInPropertytOrThrow(syncItemProperty)||The first in a set that satisfies the find criteria, looking only at the SyncItems in the given property. Returns an error in not found.|
|FindAllInPropertyOrThrow(syncItemProperty)||Returns all in a set that satisfy the find criteria, looking only at the SyncItems in the given property. Returns an error if not found.|
|csv(type)||A comma-separated string of the values.|
If no items match the find criteria, FindFirst will return an empty item, and FirstAll will return an empty set. If the property being set is an item property, it will be cleared. The function can be followed with the same attributes mentioned above for the value.
For example, FindFirst(Story)->Other->name, which means once Connect finds a story matching the Find criteria, then return the name property of the item that story is synced with. The Find Criteria is only evaluated when using one of the above functions. Use the When criteria for controlling when a calculated value should be performed.