Defining the Check Company Policy Task

The first activity after the instance is created is Check Company Policy. This is an automatic activity in which you code a simple rule to handle pre-defined approval and rejection criteria.

The reason to implement company policy in an automatic activity is to lighten the workload on supervisors, so they don't spend time on trivial cases.

The hypothetical company rules are: Any expense report totaling less than $2,500 is accepted into the approval process. Any expense report of less than $25 is approved automatically and goes directly to the Treasurer. If the total is $2,500 or more, the expense report is rejected.

To implement the company expense rules:

  1. Right-click on the Check Company Policy automatic activity, and click Main Task. The Main Task dialog box appears.
  2. In the Method section, click New. The New Process Method dialog appears.
  3. You can accept the default suggestion for the Method Name field, which is checkCompanyPolicy, so click OK.
  4. Back in the Main Task dialog box, click Edit. A PBL method editor page opens in the ExpenseReport editor.
  5. In the editor, enter the following PBL code exactly as shown:
    if report.total < 2500.0 then
    	result = "Accepted"
    	if report.total < 25.0 then
    		report.isApproved = true
    	end
    else
    	result = "Rejected"
    end

    This code implements the rule described above. Note that you never declared the result variable. This is a predefined process variable of type String, meant to be used to store a value indicating the result status of a given activity.

  6. Save your changes and then close the editor page (from the bottom tab).
You have implemented a PBL method that sets two parameters (the predefined variable result and the ExpenseReport object attribute isApproved). These parameters will be used by conditional transitions to control the process flow itself is controlled by conditional transitions, as you will see starting with the next task.