Custom IF/AND/OR formula

Hi - I am using Tools > Set Variable to generate a results for the Email Templates to be used.

I have 4 email templates with the following rules(see below screenshot if it’s easier):

  1. Category = General Enquiry AND Enquiry Language = English, it will output Template: General (EN)
  2. Category = General Enquiry AND Enquiry Language = Chinese, it will output Template: General (CH)
  3. Category = General Enquiry (Activities Page) AND Enquiry Language = English, it will output Template: Activity (EN)
  4. Category = General Enquiry (Activities Page) AND Enquiry Language = Chinese, it will output Template: Activity (CH)

I have tried many variations of the formula, and was asking the make academy guide in ChatGpt but it does not seem to be giving me the correct answer.

To keep it simple, it would be great if someone can show me how I can write the correct formula for rule 1 & 2 and I should be able to follow the login to complete 3 & 4. thank you so much!!

Hi @suetyi,

You can use the following formula to select the correct email template based on Category and Enquiry Language:

{{switch(var.input.Category + " | " + var.input.EnquiryLanguage;
  "General Enquiry | English", "Template: General (EN)",
  "General Enquiry | Chinese", "Template: General (CH)",
  "General Enquiry (Activities Page) | English", "Template: Activity (EN)",
  "General Enquiry (Activities Page) | Chinese", "Template: Activity (CH)",
  "Template: Not Found")}}

This will output the appropriate template based on the values of Category and Enquiry Language.

Notes:

  • Replace var.input.Category with the actual reference for your Category variable (e.g., {{1.Category}}).
  • Replace var.input.EnquiryLanguage with the actual reference for your Enquiry Language variable (e.g., {{2.EnquiryLanguage}}).

Let me know if you need further assistance!

1 Like

thank you very much for the help! may I know if we could write it with a IF formula, since I am more familiar with the IF functions?