Try OpenEdge Now
skip to main content
Application Developer's Guide
Developing applications with rollback support : Rollback process example
 

Rollback process example

Let us consider the following process template as an example of how to create and define a process template using the rollback process. Figure 21 represents a Purchase Request process template.
Figure 21. Sample process using a rollback functionality
The Purchase Request process contains the following user-defined dataslots.
Dataslot name
Type
Description
Product_ID
CHARACTER
ID of the requested product
Product_Name
CHARACTER
Name of the requested product
Product_Description
CHARACTER
Description of the requested product
Product_Quantity
INTEGER
Quantity of the requested product
Product_Price
INTEGER
Price of the requested product
Estimated_DeliveryTime
DATETIME-TZ
Estimated date of product delivery
approved
LOGICAL
Indicates if the order is approved or not.
The process is summarized as follows: An employee requests an item. If the manager approves the item, then a purchase order program is executed. In addition to searching for the availability of the requested item, the program can save the information in a database to track the employee order and update entries in the database. In the final workstep, "Order Approval," a manager approves the order and the order is placed.
You may want rollback functionality in the process, when the following situations occur:
*The adapter operation for the "Purchase Order" workstep fails.
*The person performing the "Order Approval" workstep does not approve this request.
Table 13 summarizes the workstep properties in this example.
Table 13. Sample application workstep properties
Workstep
Rollback point
Dataslots to be replaced
Reactivate workstep
Compensatory JavaScript
Submitter
Not set
None
Not set
None
Manager Approve
Set
Product_ID, Product_Description, Product_Quantity, Product_Price, Product_Name, Estimated_DeliveryTime, approved
Not set
None
Purchase Order
Not set
None
Manager Approve
Packages. PurchaseRequest. externalperformers.Order. clean()
Order Approval
Not set
None
Manager Approve
None
The "Manager Approve" workstep has a rollback point set to allow rollback to this workstep. The dataslot values of Product_Description, Product_ID, Product_Quantity, Product_Price, Product_Name, and Estimated_DeliveryTime can be replaced at a later stage in the process with the dataslot values from this workstep.
The Decision gateway has two outgoing links, "Approved" and "Not Approved" (default). For the "Approved" conditional link, configure the condition with "approved" dataslot value set to true.
The "Purchase Order" workstep also includes compensatory JavaScript, which can be added to reactivate the "Manager Approve" workstep and clean the database of changes the failed adapter might have made.
To define the compensatory JavaScript in the On Recovery area under the Advanced tab, click in the Execute script text area and make changes or add new script as required (Figure 22).
Figure 22. Compensatory JavaScript set for on recovery