Declare contracts
So far our process defines a sequences of events and tasks, and declares a business variable that it will instantiate and update when executed. We want to instantiate our claim
business variable using the description provided by the customer when they start the process. We will also need to update the claim with the answer provided by the employee and with the satisfaction rating provided by the customer. We need a way to collect information from the user and store it in the business variable. This is achieved using the user interfaces (web forms by default in Bonita) and based on another concept: contract.
A contract defines the data expected from the user to start a process (instantiation contract) or to execute a user task (task contract). By default Bonita offers a solution to easily build forms (see next chapter) to allow the user to view and provide data. When submitted, forms will ask the Bonita Engine to start a process or execute a task using provided data that must match what is expected by the contract.
As our contract information will be used to set business variable values, we can use a wizard that will generate the contract based on the business variable. This wizard also sets the business variable default value and generates task operations.
Create the contract for process instantiation:
-
Select the process pool
-
At the bottom of the Bonita Studio window go to the
tab -
Click on the Add from data… button
-
Leave the default options selected (Business variable, Instantiate, claim, claimInput)
-
Click on the Next button
-
Select only the description
-
Click on Finish
-
You can ignore the information message and click on OK button
You now have a contract named claimedInput of type "COMPLEX" with one attribute, description of type "TEXT". Also, as the description is mandatory, you can see in |
Now let’s create the contract for the user task Review and answer claim:
-
Select the task Review and answer claim
-
At the bottom of the Bonita Studio window go to
tab -
Click on the Add from data… button
-
Select Data: Business variable, Action: Edit, and leave other options with their default values
-
Click on the Next button
-
Select only the answer
-
Click on the Finish button
-
You can ignore the warning message and click on the OK button
We now have a contract for the step. This contract does not create a new claim but rather updates an attribute of the claim (the claim is created when we start the process). The attribute update is performed by an operation (generated for you) on the task. Select to view the operation that updates the answer attribute. |
Create the contract for Read the answer and rate it task:
-
Do exactly as you did for Review and answer claim task
-
Select satisfactionLevel as the attribute to use in the contract
You can now click on the Bonita Studio Run button to deploy and execute this updated version. You will see that you get auto-generated forms based on the contract. In the overview form, you will see the data being stored in the business variable. Note that a form will not display previously captured data. We will address that in the next chapter.