This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.
There may be a need to Add, Subtract, Multiply or Divide values in a workflow. This can be done with Functions in the K2 Five Designer.
Before You Begin
This solution uses data fields, but this can be used for any field in the Workflow. We can call a SmartObject method and Add or Subtract before adding it to a Email or Data Field. However, creating data fields when doing this is recommended. Good naming conventions will make this much easier to keep track of which values are being Modified and which are the Outputs.
1. Create 2 data fields. Name one Before Increment and one After Increment. Make sure to set these fields to Number or Decimal.
2. Create a Set Data Field event. Choose the After Increment field to be updated.
3. In the Set Data Field event drag the Formula Function into the Set Data Field event. The Formula Function is found under the Mathematical node. See the pictrue below:
4. The Formula Function will pull up a separate wizard where you can create the Formula you would like. To increment simply drag the Before Increment Data Field into the box and type +1. This will Increment the After Decrement Data Field by 1. See the following picture:
5. You can use this in conjunction with a Loop to increment a certain number of times.