Sometimes, you want to build an app where you can increase a certain number in your data by 1 or more. Maybe to add a +1 vote, or to add +1 inventory to a certain item.
Alternatively, maybe you want to decrease the stock by 1, or maybe by 5.
Using a Data Source Request action, you can use the increment and decrement dynamic variable suffixes.
To increment the Record ID value by 1:
{{ record.id.increment.5 }}
To decrement (decrease) the Record ID value by 1::
{{ record.id.decrement.5 }}
The formula for this variable is simple, and broken into 4 parts, separated by 3 periods:
β
1. Data source (record, in this case)
2. Field ('quantity', in this case)
3. Action (decrement or increment)
4. Amount (the amount to increase or decrease by).
Example
For a real life example of using this feature, you may have a set of row actions on a table block that can either increase or decrease the value of a Product's 'quantity' field by 1.
For the 'Decrease Quantity' action, set your 'Data Source Request' action. Locate the 'quantity' field in the setup modal and insert the variable as you would below:
This effect of this will take the value of the 'quantity' column for the specific row that was targeted and decrease the value by 1. For the 'Increase Quantity' version of the action, you would just use the 'increment' suffix instead. That's it!
For more information about Dynamic Variables, read the full article here.