Defining the Check Company Policy Task

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

The intent of implementing company policy in an automatic activity is to lighten the workload on supervisors, who should not need to spend time on trivial cases.

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

To define the company policy:

  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 box 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. You will note that you never declared the result variable. This is a predefined instance variable of type String, and is 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 which sets two parameters (a predefined instance variable and a BPM object attribute) according to the company policy for expense reports. The process flow itself is controlled by conditional transitions, as you will see starting with the next task.