Hi,

I read the readme text in Subscriptions and learnt how to do the conditional statement. {{!varname==value?then_text:else_text}}. Could somebody tell me, how one can use elseif in this statement. To be more clear, if variable = A do something, if variable = b, do something else and if variable = c, do something other ..

Thanks!
Jaya

Comments

salvis’s picture

You can put an entire conditional statement (including the double braces) in the place of then_text and/or else_text, up to a nesting level of two or three (try it out).

Now that you mention it, supporting replacing else_text with a conditional statement (without the braces) could actually work to an 'unlimited' level, at the expense of not being able to put both '?' and ':' in that order into the else_text. So far, the only restriction for else_text has been to not include '}}', while then_text may not include colons (':') either, so we would be giving up something valuable, but it might be a worthwhile trade...

j4’s picture

Hi Salvis,

Thank you so much fro the very prompt reply...if possible could you help with this?

user_rid = 7 = organization
user_rid = 8 = facility
user_rid = 9 = employee

{{!user_rid==9?You are an employee:{{!user_rid==8?You are a facility:{{!user_rid==7?You are an organizer:nothing}}}}}}

Shouldnt the above work then? Or am i getting it all wrong? Am trying to basically send different welcome mails based on role.

Thanks once again.

salvis’s picture

Yes, the syntax should work, except for the variables. They are not !variables anymore but [tokens]. Enable JavaScript and open the token tree to see what's available. Then start with outputting your rid as text before you try to use it in a more complex context.

j4’s picture

Just updating..

{{[user:roles]==Organization?some text for a role that is not an organization:some text here for role organization}}

Immaterial of what my role is now I get the same mail : Some text here for role organization..

Could you please tell me where I have gone wrong? And the multiple conditional statements did not work either..maybe if i could get this simple one to work, i could get that going..:)

Thanks
Jaya

salvis’s picture

First, did you try to just send

([user:roles])

? What does that give you? As long as you don't see (Organization) in the sent mail, there's no point in wasting your time with conditionals.

Second, you have the two texts in the wrong order.

salvis’s picture

Status: Active » Fixed

No follow-up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.