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:
- Right-click on the Check Company Policy automatic activity,
and click
.
The
Main Task dialog box appears.
- In the
Method section, click
New.
The
New Process Method dialog appears.
- You can accept the default suggestion for the
Method Name field, which is
checkCompanyPolicy, so click
OK.
- Back in the
Main Task dialog box, click
Edit.
A PBL method editor page opens in the ExpenseReport editor.
- 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.
- 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.