Set conditional for when each item in a list = boolean

Greetings,

I have a items in a database, and a field of “Promo” which is a Yes/No.

Basically I’m adding items to a shopping cart (an RG) and what I want to do is when there is only items in the shopping cart that have “promo = yes” then set off a different workflow as opposed to when there are only “promo = no” or a mixture of the two.

My initial instincts were a simple "RG’s list of items: each items Promo is “yes”, or alternatively “RG’s list of items: each items Promo is “yes”: count is XYZ” and so forth.

But these aren’t producing the result I expected.

As usual I tried to do a search prior to posting and came across this post from earlier in the year which seems to be the exact same conundrum I am facing - alas it went unresolved.

So I guess I’m wondering if anyone has come up with a solution in the meantime?

Thanks.

Hi there, @phillipwalsh984… if I understand your post correctly, can you add a filter to a condition on the workflow event that looks something like this?

Hope this helps.

Best…
Mike

4 Likes

Ya beat me to it. In words:

A list of yes/nos filtered by constraint “no” will have a :count of 0 if it has all “yes” items in it.

2 Likes

You know I never even thought to look for a “Filtered” option - the idea did occur to me but I think because I’ve only ever used it when performing a search I didn’t make the connection that it applies to the lists and not the search…brain fart I guess!

That’s worked perfect thanks!

1 Like

List expressions are fun. Aside: A much more natural and obvious syntax for this would be:

list_of_bools:contains no (this would be no if the list is composed entirely of yes)

But for completely unfathomable reasons, the expression builder does not include menu options for “yes” and “no” in this context. (This would be more efficient than filtering the entire list which must evaluate every item in the list. Contains (which is just .includes()) would return false immediately upon encountering a false. Not that this is a big deal, but it’s just kind of dumb.)

Edit: And I guess I should say, you can write it this way if you happen to have a “no” just sitting around. :wink:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.