February 24, 2021 at 20:39 #32858Amal VellappillilParticipant
I have a requirement to check if a field is equal to a certain value and that field value is different from its initial value, then send an email. So if I choose the available operator “is equal to”, I can specify the value. However, the second part of the condition still needs a custom function.
Consider this scenario:
Rule: If field1 (boolean) is equal Yes, then send an email.
– User creates a new item with field1 is equal to Yes. This will trigger an email. – Expected behavior.
– User edits the item and set field1 to No (did not save), but then the user changes it back to Yes (then save). This will also trigger an email. This is not the expected behavior.
The way I have worked around is to create a custom function called isNewValueDifferentFromOriginalValue which does a comparison of new value and old value (from beforeproperties) based on triggerField and return true or false. I then use this function in Linked Rules and Functions section.
Trying the “is changed from initial value” operator also requires a custom function to check whether the field value is equal to a particular value.
So my question, is there an already built in way that i can take advantage of to achieve this? If not, do you think a new operator “is equal to and is changed from initial value” can be added to the operator list? I feel like I have to add this check to prevent accidental emails from being sent for every rule.
Thoughts? Any insight will be appreciated.
February 25, 2021 at 18:06 #32861Alexander BautzKeymaster
You can do this by using two rules. The first one is using the “is changed from initial value” and does not have any “actions”.
The second one uses the “if field equals” and then has the name of the first rule in the “Linked rules and functions” textarea. This rule has the send email action.
Now the second rule will only evaluate to true if both rules are true.
Let me know how this works out.
February 25, 2021 at 21:41 #32863Amal VellappillilParticipant
Yes that would work also. However, as you can imagine if we have 20 rules or so, that means we will need another 20 rules to make it work. Its better to use customJS at that point to check if the value changed based on the ruleID and triggerField.
Do you think this can be a feature added to a future release? A new operator or a checkbox next to the operator dropdown asking “is changed from initial value”? I think it will help.
Thank you for taking the time to provide a solution.
- This reply was modified 1 month, 2 weeks ago by Amal Vellappillil.
February 26, 2021 at 10:37 #32871Alexander BautzKeymaster
Good idea – I’ll see what I can do in a future release.
- You must be logged in to reply to this topic.