Calculations on forms
From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS
<keywords content="keywords"> Buttons, Sequence, Calculations, Webforms calculations </keywords>
Example of Calculations in Forms
Somtimes, users may need to make some calculations or call web services or perform some business rules in forms without leaving the current activity. In these cases, the user can create a button on the form and then associate an Expression with the required operations.
Example: In an Invoice Payment Process (which is a subprocess of a Purchase Request process) the Administrative Department of a company needs to pay an account with a check. The Check Number with which the Invoice is to be paid must be a consecutive number. In the next example, a sequence object will be used to obtain the next number and set the result in the Form. This can be used to obtain automatically the number of the check, or other documents.
1. Create the sequence in the Sequence Editor in Bizagi Studio.
Create the sequence and click Save.
2. Go to the Generate Check activity in the Invoice Payment process. Open the form of the activity.
3. Drag a Button render from the top tools menu, and drop it below the Check Number in the form.
4. In the properties window of the Button render, select and click the Expression option to create the expression that the button will execute when the user clicks on it.
5. Create the expression with the following code:
var Check_Number = CHelper.GetNextSeqValueStr("SEC_CHECK");
<idInvoice.CheckNumber> = Check_Number.ToString();
The GetNextSeqValueStr function, will return the next number in the sequence object.
Then this can be set into the CheckNumber attribute using Xpath. Take into account that the sequence is an integer data type, but in the data model the CheckNumber attribute is string data type. So the ToString() function must be used from the .Net framework.
In the button expression Bizagi can perform any calculations using Xpath, functions, web services etc.
6. Now, the next step is to test the button. Create a case and click the button in order to obtain and set the sequence number. The function ThrowValidationException can be used, from the CHelper method, if any warning messages are needed to be informed to the end user.
To call a Web Service, use the Interface option instead of Expression option in the Properties window.
Related Articles
Expressions
Buttons
<comments />