Conditional IF - testing a bool - unexpected result

Options

I am iterating through a list of users, so as to send them an email.


A user can choose to not receive email. This is set in the table Settings with property 'canemail' which is a bool. False means - 'Don't email me'.

In the screenshot below you can see that I test canemail - Stop and Debug shows that, for this record, the value is 'false'.

However, the If test var: can_email=true has therefore failed. In fact all emails, whatever the value of canemail, are being sent.

Can anyone shed any light on this?

Thanks!

Best Answer

Answers

  • Max
    Max Member
    Options

    I would do it different way, in your can_email generation step, simply set output type to exists, and filter how you need, THEN it will return a proper bool true\false statement to work with. like so:

  • Mr_English
    Options

    @Max Thanks for responding. I looked at Preconditions. I don't think they work in a foreach loop.

    The text says: "SET CONDITIONS THAT MUST BE TRUE

    If not met, the request will stop. You can also specify an error message below."

    I tested it in a loop and it halted the loop when can_email == false.

  • Max
    Max Member
    edited October 2023
    Options

    ignore precondition part mate :D i just showed you mine example how i get proper true\false from search in table. Of course use that same method how you need, in your case i would use its result in your if statement like so - can_email === true, just mod can_email step to return a proper statement like on mine example


    PS for single record you can play with "Record exist" element in Xano too, it also return proper bool, i am just not sure you can have a complex query search there.

  • Mr_English
    Options

    @Max Putting it down and having a cuppa helped.