You can use the compensatory enable process to write compensatory JavaScript codes to handle a rollback request. For example, write JavaScript code in a process template using rollback points for the following cases:
Send messages or e-mail notifications before running pre/post-functions for a second time or for undoing process effects regarding these functions.
Send e-mail notifications to a computer where an asynchronous nested process is running.
Actions applied for rollback to a loop.
Compensatory JavaScript also works as pre- and post-functions for worksteps and cleans all activities completed by this workstep, such as deleting generated files or removing new database entries.
To write the compensatory JavaScript code, complete the following steps:
1. Click the workstep to which you want to rollback.
2. From the Properties view, click the Advanced tab, and then the On Recovery tab.
3. Write your code in the Execute script text area. BP Server sets the compensatory JavaScript for this workstep.
In BP Server, if you write the compensatory JavaScript, then it is compiled and inserted automatically into the XML file, similar to how pre- and post-functions are compiled. You can use compensatory JavaScript in any workstep, whether or not Create Rollback Point is selected for the workstep. The compensatory JavaScript is executed only when a rollback is requested by you or by the BP Server through a workstep’s execution failure (described in the next section).