Use of Constants for Set Value Actions
The following section will list a couple of examples for User Defined Constants, specifically for the use with the Set Value Actions.
The difference to the previous examples is that the SOURCE of the information are FIELD VALUES from the CURRENT RECORD, and not system variables like SYS_TODAY or TIME.
For example:
- Set the Action Due Date to be 14 days from the Date the Action was raised.
- Calculate the Total Cost of a Change Request by multiplying the Daily Rate with the estimated Duration.
Source and Target Field are on the same Component
Defining the Constant
|
For the Task of
|
You will have to
|
Identifying the ID of the Field I want to use as the Source for my calculation.
For example: To be able to add 14 days to the Date an Action was raised, I need to identify the ID of the field Date Raised on the Action Form.
|
- Access the Form Designer, and edit the Form which contains the Source Field
- View the Field Properties for the Field
- Copy the last part of the Field Id. For example, for the Field Date Raised on the Action Form (full ID = bms_9999999_109:9999999_1133), that would be: 9999999_1133
|
Defining the XML for the Constant
|
- Start building the "shell" for the desired calculation. For example, to add 14 days to a date field, that would look like that:
<Function name="Add">
<Value type="date" value="" />
<Value type="date" value="14" />
</Function>
- The "blank" value will need to be filled in to point to the Source Field. To do this, you need to use the ID from above, plus a prefix of "bms_". In our example, that would be: bms_9999999_1133.
- The complete XML code therefore would be as follows:
<Function name="Add">
<Value type="date" value="bms_9999999_1133" />
<Value type="date" value="14" />
</Function>
- Finally, save the Constant
|
Using the Constant in a Set Value Action
|
- Go to the Action Designer
- Create a Set Value Action, and set the Value of the Target Field
With Constant = <Name of the Constant>
|
Source and Target Field are from Related Components
To identify the Source Field for a Related Component is a bit more involved since it is necessary to identify the correct format to describe the Relationship.
Defining the Constant
|
For the Task of
|
You will have to
|
Identifying the ID of the Relationship and the Field I want to use as the Source for my calculation.
For example: To be able to set an Action Due Date to be 14 days after the Incident Date Raised, I will need to identify the Path, and Field ID of the field Incident Date on the Incident Component, from the perspective of the Action Component.
|
The easiest way to identify the correct path is via a Condition Builder, for example the one used in Component Security.
Access the Component Security for the Component which contains the Target Field. In this example: the Action Component.
Create a new Role Permission and create the filter.
Navigate to the Field which you want to use as the source (in this case: Incident:Incident Date), and define any condition.
Once done, view the "Source"
Copy the content of the LHS argument, In this example, that would be: bms_FK_9999999_131_ID.bms_9999999_1020
|
Defining the XML for the Constant
|
Start building the "shell" for the desired calculation. For example, to add 14 days to a date field, that would look like that:
<Function name="Add">
<Value type="date" value="" />
<Value type="date" value="14" />
</Function>
The "blank" value will need to be filled in to point to the Source Field. To do this, use the path from the previous step . In our example, that would be: bms_FK_9999999_131_ID.bms_9999999_1020.
The complete XML code therefore would be as follows:
<Function name="Add">
<Value type="date" value="bms_FK_9999999_131_ID.bms_9999999_1020" />
<Value type="date" value="14" />
</Function>
Finally, save the Constant
|
Using the Constant in a Set Value Action
|
Go to the Action Designer
Create a Set Value Action, and set the Value of the Target Field With Constant = <Name of the Constant>
|
|