You are viewing the documentation for Blueriq 14. Documentation for other versions is available in our documentation directory.

TSL IF ELSE statement


The IF ELSE statement enables you to selectively perform tasks within your TSL message, based on some criteria, which evaluate to TRUE or FALSE.

When TRUE executes the task specified in the IF part of the statement, in all other cases executes the task specified in the ELSE part of the statement.


Syntax

[[[IF expr]]] message1 [[[ELSE]]] message2 [[[/IF]]]


Inputs

  • expr: is an expression that evaluates to TRUE or FALSE
  • message1 and message2: are TSL messages, so they can contain plain text and other TSL conditions


Example

Suppose you want to create a welcoming message after a user has logged in to your application. Then you could create the following TSL message:

Welcome [[[IF user.gender = 'male']]]Mr.[[[ELSE]]] Mrs.[[[/IF]]] [[[user.first_name]]] [[[user.last_name]]]

When user John Doe logged on, the message shown in your application is: “Welcome Mr. John Doe”

If the gender is unknown the message will look like this: “Welcome Jane Doe”

Back to Top