Previous Topic: Restricting the Display of Tasks

Next Topic: Generating and Building

Adding Commit and Rollback Processing

When end users use a wizard, you give them the option to go back and change things, or to cancel the whole process before they click Finish. If they change their minds and cancel out of the wizard before clicking Finish, you do not want anything added to the database.

You can define your wizard so that it remembers what end users enter, but does not write anything until they complete the process. In database terms, you commit the changes when you are ready to write the records (the end users click Finish). The opposite of commit is rollback, which lets you cancel any changes in memory without making any changes to the database. You can use this when end users click Cancel.

To add commit and rollback processing:

  1. Set the Object Browser to display functions.

    Adding Commit and Rollback Processing (1)

  2. Drag the Project Wizard function from the Object Browser to the body of the Model Editor, and then add the following triple:

    Project Wizard commit SYS Parent

    This enables the Project Wizard function to commit and rollback the database.

  3. In the Object Browser, select Project Wizard and click the Editor button.

    Adding Commit and Rollback Processing (6)

    The Action Diagrammer appears, with the Select Edit Point dialog over the Action Diagram window:

    Adding Commit and Rollback Processing (2)

  4. Select the Post Point that follows the Process Finish Request Edit Point, and click OK.

    The Process Finish Request Edit Point corresponds with the end user clicking the Finish button.

    The Action Diagrammer appears with the Post Point highlighted:

    Adding Commit and Rollback Processing (3)

  5. In the input line of the window, enter Commit and press Enter.

    The statement is added to the body of the window:

    Adding Commit and Rollback Processing (4)

    In Step 2 you added the triple Project Wizard commit Parent. This indicated that you want to do commit/rollback processing. Adding the Commit statement indicates when you want the transaction committed.

  6. Double‑click the up arrow ( Adding Commit and Rollback Processing (5) ) next to the Post Point name in the action diagram.
  7. Enter Start cancel request in the input line, and press F4.

    The Action Diagrammer moves to the Pre Point before the Start Cancel Request Edit Point. This Edit Point corresponds to the end user clicking Cancel on the wizard.

  8. Double-click the Post Point after the Edit Point.
  9. Add the statement Rollback.
  10. Save your model and close the Action Diagrammer.

    Now, when end users cancel out of the wizard, no records are written to the database, and when the end users click Finish, the records are written to the database. In the next section, you generate, build, and test the wizard.