Kentico newbie trying to display conditional text messages in email notifications

Michael Joncas asked on February 24, 2020 23:05

I have been given primary responsibilty for developing and maintaining our Kentico intranet. However, I am brand new to kentico and running into an issue while trying to construct a custom email notification message on a form I have created.

I want to insert a bit of logic to customize the text that is displayed in the body of an email message. For example: if a user selects a radio button option labeled "New" I want to display text: "For Who?". If they select the option labeled "Replace" then I want to display "Current Phone Number".

I have tried statements like this: {% if (opt_CellNewReplace.Value="New") {"For Who?"} else {"Current Phone Number"} %}

Sorry if this is a basic question, but I have been looking through the documentation and have not been able to find anything that helps.

Recent Answers


Peter Mogilnitski answered on February 25, 2020 02:36

{% if (opt_CellNewReplace.Value == "New") {"For Who?"} else {"Current Phone Number"} %}

or {% opt_CellNewReplacef.Value == "New" ? "For Who?" : "Current Phone Number" %}

1 votesVote for this answer Mark as a Correct answer

Michael Joncas answered on February 25, 2020 18:53

Thanks. That got me a little closer to what I need. I am using this in a table in the email body: {% opt_CellNewReplace.Value == "New" ? "For Who?" : "Phone#" #%}

When this runs, it always uses "Phone#" in the message, regardless of which option is selected. I know for a fact that opt_CellNewReplace.Value returns either "New" or "Replace" because I am displaying that value in another part of the table.

Any suggestions?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 25, 2020 23:05

You may try casting to a string and to a lower value like so and comparing.

{% ToLower(ToString(opt_CellNewReplace.Value)) == "new" ? "For Who?" : "Phone#" %}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.