Define calculated values
This topic describes calculated values, 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”.
In this topic:
- Overview
- Add a calculated value
- Synchronize reference fields
- Assign items to a default user
- Functions
- Example: Uni-directional mapping
- Example: Jira bug mapped to an ALM/QC requirement
- Example: Azure DevOps to ALM/QC mappings
Overview
Calculated values are field values that are automatically set during synchronization, when the specified conditions are met. For example, you can define a calculated value rule that automatically sets Tested to "false” when a connection creates a new story.
This example uses the FindFirst script to set a reference.
The example below de-references the ALM Octane parent story to set a Jira Bug text field to the parent’s name.
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 Add projects and rules to a connection.
Note: If you do not specify a When query, the Calculated Value is always applied when an asset is synchronized.
-
In the Set Field drop down, 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. These functions discover the item according to the criteria you specify. For a list of the available From functions, see Functions.
- For date fields, you must use the long date format with an offset specifier:
YYYY-MM-DDTHR:MIN:SEC+/-OFFSET.
For example, 2016-01-01T00:00:00+00:00. Other formats result in an error.
-
If you entered a function in the To Value field, define a From query. For details, see Add projects and rules to a connection.
-
Click OK to save.
Synchronize reference fields
You can use Micro Focus Connect to synchronize reference fields, by creating linkage to the referenced entity.
For example, suppose you are synchronizing a Jira project with an ALM Octane workspace. The Jira bugs and ALM Octane defects have a Release field. In ALM Octane, the Release field is a reference field, meaning that its value is linked to a release entity in the workspace. When creating a defect in ALM Octane, Micro Focus Connect can populate the Release field with the appropriate value, and also link the value to an existing release entity in ALM Octane.
To create a link between reference fields in the Set Field section, you can use the FindFirst functions. These functions search for an item in the product's database that matches the criteria defined in the From section. For details, see Functions.
To find the matching release, you must refer to the field value in the item being synchronized. To do so, use the My->fieldName
or Other->fieldName
variables.
- Use
My->fieldName
to refer to the product for which you are creating the calculated value—target or master. - Use
Other->
to refer to the product on the other end of the synchronization.fieldName
Note: For fieldName
, specify the field's system name—not the field's label.
The following example demonstrates synchronizing the Release field in an ALM Octane defect:
For other examples using functions and variables, see Calculated value use-case.
Assign items to a default user
You can use calculated fields to set user fields, such as Assigned to and Detected by to a different user, other than the one set in the starting endpoint.
For example, at one endpoint, users 1,2,3, and 4 detected defects and assigned them to users 5, 6, 7, and 8. When you migrate the defects to another endpoint, you want to assign all of them to user 9.
To assign the defects to another user:
-
Open the Add Calculated Value screen. For details, see Add a calculated value.
-
Set a calculated value for the target. For example:
Set field: Assignee
To value: Person # 9 Display Name
In this example, defects are always assigned to a specific default user, Person #9 Display name in Jira, regardless of who created the defect, or who it was assigned to in ALM/QC.
Tip: This strategy can be used for any user field, such as the Jira reporter field.
Functions
You can dynamically set field values using functions. Functions are usually used in combination with values or variables in the From area.
General functions
Function | Result |
---|---|
Max(type, property) | The largest of a set. |
Min(type, property) | The smallest of a set. |
csv(type) | A comma-separated string of the values. |
Find functions
Function | Result |
---|---|
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. |
Date and time functions
These functions support relative date and time calculations using this syntax:
FirstFunction([param]).subFunction([param]).subFunction([param])
Function names are case insensitive.
Function | Result |
---|---|
Now([TimeZoneSpecifier]) |
The current time in the specified time zone. TimeZoneSpecifier can be in the following formats:
|
Today([TimeZoneSpecifier]) |
The current date in the specified timezone. For example,
Tip: This can also be retrieved using |
The following table lists the sub-functions that are supported for the date and time functions. All parameters for the sub-functions are numeric.
Action | Sub-function |
---|---|
Add time |
The following sub-functions allow you to add to the current date or time:
|
Subtract time |
The following sub-functions allow you to subtract from the current date or time:
|
Truncate the date string |
The following sub-functions allow you to truncate the date or time string:
|
This following examples illustrate some common uses of these functions.
When using sequential sub-functions, each sub-function uses the value returned by the previous sub-function.
Example | Result |
---|---|
Now().TruncateMinutes |
12/03/2021 13:00:00 |
Today(UTC+12).TruncateHours |
12/03/2021 00:00:00 |
Now().PlusHours(5) | Five hours ahead of the current synchronization time. |
Today().PlusMonth(1)) |
One month ahead of the current synchronization date. |
Now().PlusHours(2).MinusMinutes(2).TruncateSeconds |
One hour and fifty-eight minutes ahead of the current time, hiding the seconds. |
Example: Uni-directional mapping
This section provides an example of a uni-directional mapping of an ALM Octane (Master) List field to a target string field.
Create a calculated value for the target of the connection, for example Jira or ALM/QC. For details, see Add a calculated value.
Follow the format shown in the image below, where the ALM Octane Detected in Build field is mapped to the target’s string field.
.
Set a calculated value for the target. In this example:
-
Set fields: Custom String Detected in Build (Jira or ALM/QCfield)
-
To value: Other -> Detected in Build.label
Example: Jira bug mapped to an ALM/QC requirement
This example shows how to map a Jira bug to an ALM/QC requirement using a calculated value.
To perform this mapping, create a new ALM/QC requirement as a child of an existing one, whose name matches the name of the related Jira bug.
In this example, the following syntax gets the name of the bug from the Jira Epic link:
My > Other > Epic Link > Epic Name
Example: Azure DevOps to ALM/QC mappings
This example shows how to map several fields in Azure DevOps to ALM/QC using a calculated value.
Azure DevOps Resolved to ALM/QC Fixed
To perform this mapping, add a calculated value rule setting the ALM status to Fixed:
ALM/QC Fixed to Azure DevOps Resolved
This mapping will need to be done in two stages, since you cannot perform two update operations with a single calculated value. Also, in Azure DevOps, a Reason cannot be set to Fixed before setting the State to Closed.
To perform this mapping, first add this calculated value rule to set the State:
Then add an additional rule to set the Reason:
See also: