Today’s release includes improvements with how the State Stays feature in the Rule Engine works with Variables.
With this update, State Stays triggers for Variables only use the initial state change for determining if a variable state has stayed the same.
Previously, if a variable was updated with the same value, it would trigger the State Stays condition for every update. For example, if a variable was initially changed from
true and then subsequently set to
true again, the State Stays trigger would fire for every subsequent
To work around this, you previously needed to use an IF Condition to determine if the target variable should be updated. Something like
IF $isOn is not true, then set $isOn = true. With the release of this enhancement, you no longer have to avoid updating the variable with the same value to prevent State Stays Triggers firing again with subsequent updates.
That also means that if you intentionally want to cause a State Stays trigger to fire again, the variable must first change state. (eg. change to
falseand then back to
This does not impact normal equality / comparison checks as an event is still fired each time a variable is updated. This only impacts ‘state stays’ triggers.
Perhaps more importantly, this resolves a bug where State Stays triggers could incorrectly fire in certain scenarios. If the State Stays trigger entered ‘pending validation’ and within the state stays duration it changed to a different value twice in a row (eg. the same ‘other’ value twice), it would incorrectly get treated as having stayed the same value even though it had changed from the original value.
For example, let imagine you had a Trigger based on a variable staying
true for a period of time. If that variable changed to true it would enter the pending validation state as the rule waited to see if the value stayed the same for your desired duration. If the variable was quickly changed to false twice or more before the State Stays period expired, the Trigger would incorrectly fire when it shouldn’t have.