I am not sure how to efficiently handle some conditions.
I have a user which updates its preferences about receiving or not 2 newsletters (named: Dogs and Cats). When the user changes his/hers preference, my trigger outputs me a previous situation and the current situation of that user.
My trigger gives me this type of data:
{
"current": {
"email": "email@email.com",
"name": "Test",
"newsletters": [
{
"id": "67c9b991159234000122c01e",
"name": "Dogs",
}
]
},
"previous": {
"newsletters": [
{
"id": "67c9b991159234000122c01e",
"name": "Dogs",
},
{
"id": "67d54f71792e6b00019aae19",
"name": "Cats",
}
]
}
}
I am only interested in the newsletter array.
The above example is when a user had both newsletters active (Dogs and Cats) and disabled only Cats, remaining only with Dogs.
I want the scenario to execute ONLY if the Dogs newsletter preference has changed. But my trigger activates whenever something gets updated from the user side so I can’t stop the trigger to activate, I need to filter right after the data arrives.
The newsletter array is empty when no newsletters are active.
I created this summary table to check when I want the scenario to execute and where I don’t. In these 4 cases I do not want my scenario to continue.
Column 1 | Column 2 | Column 3 | Column 4 |
---|---|---|---|
PREVIOUS | CURRENT | CONTINUE SCENARIO? | |
empty newsletter array | only Cats enabled | NO | |
both newsletters are active (D & C) | Cats gets disabled | NO | |
only Cats are active | Cats get disabled | NO | |
Only Dogs are active | Cats get enabled | NO | |
i decided to check if newsletter array has ID of the two newsletter. I tried like this (the filters are more than that but could not fit into a screenshot):
I put those here:
But it is not working.
My scenario should continue in the “fallback” route if any of those conditions are met.
How to do that?