Example get and set XPath
From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS
<keywords content="keywords">get(i), setXPath, getXPath, Parameter</keywords>
Contents |
getXPath and setXPath introduction
You can also navigate through the data model to obtain of set values, using Xpath with the following functions (Xpath should go in double quotes):
Me.getXPath("XPath")
Me.setXPath("XPath",value)
You can use < > diamond brackets or the mentioned functions indistinctly.
The following expressions are exactly the same:
ExampleVariable = <Request.Clients.Age>
ExampleVariable = Me.getXPath("Request.Clients.Age")
<Request.Clients.Age> = ExampleVariable
Me.setXPath("Request.Clients.Age",ExampleVariable)
When collections have to be filtered using variables it is NECESSARY to use setXPath and getXPath functions. In those filters the diamond brackets cannot be used '< >' .
The following is how a filter with variables should be written:
Me.getXPath("BusinessEntity.Fact[AttributeName= "+ variable +"]")
Please refer to FILTERS for more information and examples about filtering collections
Example
In a credit process, there is a control to check that all customers aged 45 years and above are asked for additional insurance. The get(i).setXPath is used to review all customers entered in the request and to mark those who require insurance.
This is the process:
Customers are entered in the Request activity by the User and in the Pre-Approval activity the Risk Management user has to identify easily which customers require additional insurance.
This is how the information will look in the first activity.
This is the result should be in the second activity.
To achieve this result it is important to identify in the Data Model where the required information is found.
Notice that a request may have more than one customer and a customer may be in more than one request (many-to-many relationship). Also, an unlinked entity called Parameter is created in order to make the reference to age (in this case 45). This is easily modifiable from the Web Application at any time.
The rule to accomplish this task is as follows:
These are the variables that were declared at the beginning of the rule.
The first Expression "Get Valid Group" should be expressed in the following manner:
In the first part of the rule, the value of the age that requires insurance is found from the unlinked table called Parameter. It is a good practice to use a Parameter entity to save the values that may change in time and that affect Expressions. This allows changes to be made easily from the Web Application. The Parameter table looks like this:
Note: A column named Code is created as a reference because the id should not be used for this type of situation.
In the second part of the previous expression Get Valid Group, all customers who are 45 years and older are saved to be reviewed, one by one, by the following FOR Expression.
Finally, to mark each of the customers who are 45 years or older, the expression Set Field uses the expression get(i).setXPath as follows.
This rule is saved and associated in the process as an Action On Exit of the first activity.
Store records of a collection in a field
You can store several elements contained in a grid on a single attribute, as text separated by comas using a simple expression.
Suppose you have a process called ProcessA The business process entity is called EntityA and it has a one-to-many relationship with EntityB. The relationship is called CollectionB. EntityB has an attribute called TargetAttribute, that is string-type. Additionally EntityA has an attribute called AttributeC where the information will be stored.
The expression has the following structure:
var List = <EntityA.CollectionB.TargetAttribute>; <EntityA.AttributeC> =Convert.toString(List);
Suppose you have a customer database, and for each customer there are some related contacts. You need to invite some companies (which are you customers and their contacts) to a meeting, so you need to obtain the list of people invited in an extended text field. You can use the following expression:
var List = <ConferencePreparationProcess.CompaniesInvited.Contacts>; <ConferecePreparationProcess.ExtendedTextField> =Convert.ToString(List);
The grid of companies invited and the resulting list of contacts are shown below:
Related Topics
<comments />