Specifying remote API /createMessage conditions (OR/AND)

Comments

1 comment

  • Avatar
    Gary Fenton

    What I did was create a value "none" for tags where users didn't set a value for it. So "none" means "nothing selected" because Pushwoosh doesn't accept a null or empty string when creating conditions.

    "conditions": [["siteId", "IN", ["10"]], ["business", "IN", ["2","none"]], ["subscriptions", "IN", ["contests","none"]]]

    It will send a push if any of these conditions are true:

    siteID=10 and business=2
    siteID=10 and subscriptions=contests
    siteID=10 and business=2 and subscriptions=contests
    siteId=10 and business=none and subscriptions=none
    

    This is almost what you need except for the last scenario.

    If you can spare using another tag there is a workaround but it will require a little bit of logic in your app when setting the value of the tag. Create a new tag that in an ideal world we'd called "business_and_subscription_is_none", but we'll have to settle for "bizsubnone". In your app if both business and subscription settings are empty (or none) then set the tag bizsubnone to 1. It's a bit flag so the default value would be 0 meaning either subscription or business has a value. Then use this condition logic:

    "conditions": [["siteId", "IN", ["10"]], ["business", "IN", ["2","none"]], ["subscriptions", "IN", ["contests","none"]], ["bizsubnone", "IN", ["0"]]]

    This is the answer to your question although I don't know how it will impact any other conditions you might want to include. But I hope you get the idea and can expand on it.

Please sign in to leave a comment.