Adding the Not Confirmed Transition

In this task you add the last conditional transition of the Expense Report process. This transition is to be used when the treasurer has not confirmed one or more receipts.

Because we don't know the number of items in an expense report beforehand, we need to code a loop that will check the status of each receipt.

You could place this loop in the conditional transition itself, but it's better if you define a method. In this way, you will be able to use the method elsewhere. If any changes are made to the way this information is stored in the BPM object, you will need to update only one piece of code.

Finally, the conditional expression in the transition itself will be simpler, and thus easier to read and maintain. It is good practice to use simple expressions within conditional transitions.

You will define the areReceiptsChecked method and then add the Not Confirmed transition, which will use it.

To add the areReceiptsChecked method and the Not Confirmed transition:

  1. In the Project Navigator, right-click on the ExpenseReport BPM Object, and click New > Method. The Method dialog box appears.
  2. Enter areReceiptsChecked in the Method Name field, and click OK. A method editor opens.
  3. In the Properties Window, set the Return Type property to Bool.
  4. Enter the following code into the editor, exactly as shown:
    for each item in items do
       if not item.receiptChecked then
          return false
       end
    end
    
    return true

    This code will return false if any item has not been checked. If all items have been checked, it will return true.

  5. Save and close the editor.
  6. In the process design editor, right-click on the Confirm Receipts activity and click Add conditional transition(Conditional Transition icon 
				). The mouse cursor will begin dragging a transition line originating from the Confirm Receipts activity.
  7. Click on the Edit Report activity. The Transition from Activity dialog box will appear.
  8. Enter Not Confirmedin the Name field.
  9. Go to the Properties page of the dialog box. In the conditional expression text box, enter the following expression:
    not report.areReceiptsChecked()

    This expression will return true if areReceiptsChecked returns false.

  10. Click OK. The Not Confirmed conditional transition is added.
  11. Save your changes.

After completing this task, your process design diagram should look like this:

Figure 1. Expense Report process with Not Confirmed conditional transition