Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
How to execute basic operations(Addition, subtraction, multiplication and division) in workflow?
For example:
My workflow has 2 workflow variables: v1,v2
After assign value to v1,v2, how to change v1 value automatically by operation: v1=v1+v2?
3 Comments
Tiensoon
One of the feasible solutions, is by using BeanShell Plugin.
BeanShell script is written with Java syntax, so the arithmetic operations could be easily accomplished.
In BeanShell plugin, you could refer to a workflow variable's value by using Hash Variable, such as #variable.variableName#
At the same time, you can also use the sample code as shown in BeanShell Plugin documentation, to set value to a workflow variable.
Tiensoon
To further elaborate, this is the sample BeanShell script with reference to my suggestion:
Alternatively, you can also choose to perform the arithmetic operation using JavaScript, in the form. For example, using JavaScript, calculate the summation of values from the first and second text field. Then, set the sum to a hidden field that's mapped to a workflow variable.
Nguyen Sy Thanh Son
OK, i see!
Thanks for your deep answer!