Scopes
From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS
Long Term Transactions (Scopes)
Bizagi is a collaborative tool that allows many users to work on the same process at the same time. To ensure the integrity of the information, Bizagi use a concept called Long-term transactions. This is an essential technology used when many people work on a project simultaneously, to prevent different users editing the same data. In Bizagi this technology is called Scopes.
To this end, the information of all activities is stored in the Scope and only updates the database when the user clicks the Next button. When a user is entering information into the Web Portal, it can be saved by clicking the Save button and the case can be continued later. However, this information is not validated until the user clicks Next, at which time the rules that ensure data integrity are run, i.e. when the user is sure he wants to end this activity.
Included in the validation are expressions that validate mandatory fields.
In the event that the user clicks Save (Save) the information will remain in the Scope of the activity and not in the database.
The mechanism for accessing information of any process is via XPath. XPath navigates the process data anywhere: forms, business rules, expressions, letters, notices, etc.
In some cases it is necessary to update or reference information from an external system, submitting the web form without leaving the activity within the process. In such cases we must take into account:
- It is necessary to use expressions to send or obtain information from Bizagi using an external system (Bizagi is the trigger). Utilitarian Methods for Using XML in Business Rules WithScopes methods will be used.
- If you are sending information from an external system to an activity in Bizagi, the XML originating from the external system must contain the Bizagi case information and activity.
Example 1 : Send Information To An External System
The following case shows how to use the SOA WithScopes method to send information to an external system. This is useful to validate or obtain information from an external system without leaving the activity.
In a Purchase Request Process it is necessary to know whether the products are in stock at the time the user requests the products. In this case, a Button can be created on the form to run an expression in which data will be taken from the Scope to create an XML and call the external service. Then, the response from the external service is stored in the Scope of Bizagi to display on the same table the products that are in stock.
1. Check the data model of the process to create a new attribute(bool) that will indicate if the product is in stock.
2. We must then create the schema within Bizagi Studio that will be used to call the interface. The scheme must be generated taking into account the Business main entity (in this example, the entity is Purchases) and a transformation (XSL) is created according to the external service schema. For further information on how to create these diagrams, see the article Xml Schemas.
3. We must change the activity of the process to show the attribute (flag) and the button below the grid that will execute the expression.
4. When creating the expression, it is advisable to create two variables (string) . Then, we can create two expression boxes and one interface box. The first expression box is to obtain the information of the products. In the interface box we will send that information to the external system and in the final expression box we will transform and save the response from the service.
Double clic the Interface box to start the wizard. All the configuration of the Interface Box will remain in the Systems and Interfaces configurations of Bizagi.
Select the method of the web service.
Select the variable that contains the information to send to the external system (sRequest)
Select the variable that will save the response of the service.
5.Finally, take the response from the service and save it in Bizagi. A transformation is normally used before this step, but in this case it is not necessary. For further information about transformations in Bizagi follow this link.
The service being invoked in this example, simply checks the product code, modifies the information sent by Bizagi and changes the value of InStock tag within the communication message. For this reason fromXmlToEntityWithScopes method is used to ensure the response is received before saving the information into the database.
After clicking the button on the form we have all the information (request and response) in the Scope of Bizagi. This information is not stored in the database until the activity is completed, as outlined at the beginning of the article.
We have a flag on the collection indicating that a product is in stock. It can be used to:
- Identify products that are in stock with the ones that are not, and display in a form only the former.
- Remove records not marked with the flag.
- Filter or group the display of a table to separate information separately.
Example 2 : Information Received from External Systems
When it is necessary for an external system to send information to Bizagi it must use methods of the Bizagi SOA Layer to send information directly to the Scope and not to the database.
For example, suppose that we need to obtain requests pending for approval from an external system. This information is found in the Authorize Request activity in the Purchase Request process.
1. The external system must call the WorkFlowEngineSOA web service and invoke the getActivities method.
2. The answer received from the service will contain the required information.
If the system knows the current status of activities, and also needs to update information on these activities, it must be saved into the Scope and not into the database. In this situation, the external system must use the saveActivity method from the WorkFlowEngineSOA service.
Suppose then that the external system user wishes to approve a certain request but cannot do so from the Bizagi screen. In this case the external application must send the XML information to the activity. Furthermore, the information to be updated or created within the activity must be entered in the <Entities> tag. The structure of the <Entities> tag is based on the Bizagi Data Model.
The XML must contain the main entity tag <Purchases> followed by the master entity tag <PurchaseRequest> together with the attribute with the user response. The reponse must contain the code of the state of the Request (Approved, Rejected etc). In this case, the response is Approved. In the parametric entity the code for this value is AP.
The Bizagi rad number for this example is PR1009 that was obtained in the last step.
The Request XML should be as follows:
When the external system sends the response, the information will be saved in the Scope of the activity and not in the data base.
For further information on this topic, follow these links:
Advanced Options to Invoke Webservices <comments />