Jump to content

ESP Condition Expressions


SJEaton

Recommended Posts

Hi

I want use ESP conditions to only present information in an email template if certain things are true.  I know this works for simple expressions like '{{.H_custom_o}}' = 'DatixQ (DCIQ system)' OR '{{.H_custom_t}}' = 'DatixQ (DCIQ system)' but I want to include another layer into this expression to look at another custom field too (e.g. is it this, or this, and this).  Can AND, OR and CONTAINS be used in ESP Condition expressions?  Do I need to use brackets too? 

I've checked the wiki but it doesn't give many examples, hence my question. Thanks

Sam

Link to comment
Share on other sites

1 hour ago, SJEaton said:

I want to include another layer into this expression to look at another custom field too (e.g. is it this, or this, and this).  Can AND, OR and CONTAINS be used in ESP Condition expressions?  Do I need to use brackets too? 

@SJEaton yes, any logical operator can be used. For brackets, depends on expression and operator precedence.

This should be helpful describing what operator precedence means:

 

Link to comment
Share on other sites

Hi @Victor

Thanks, its good to hear any logical operators can be used in email template ESP conditions and thanks for the info, but I'm still struggling to get my ESP condition expression to work.  I've tried multiple versions with no success. 

 

What I'm trying to achieve is: 

Global Variable -> Custom K = Basildon

AND

Global Variable -> Custom O = INR Star

OR

Global Variable -> Custom K = Basildon

AND

Global Variable -> Custom T = INR Star

 All of the following don't seem to work and no value is pulling through:

'{{.H_custom_k}}' = 'Basildon' AND ('{{.H_custom_o}}' = 'INR Star' OR '{{.H_custom_t}}' = 'INR Star')

('{{.H_custom_o}}' = 'INR Star' OR '{{.H_custom_t}}' = 'INR Star') AND '{{.H_custom_k}}' = 'Basildon' 

'{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star' OR '{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star'

('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star')

 

What's the version that I am missing that will actually work?

Thanks

 

  • Like 1
Link to comment
Share on other sites

@SJEaton

('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star')

Should be the correct syntax and assuming the condition is met, it should display the value. Also, make sure it has not formatted the brackets, quotes and such in the template source. When you click on Source to see the email template source, the condition should look like this:

image.png

  • Like 1
Link to comment
Share on other sites

Hi @Victor

It seems this syntax is still not working.

I think the condition in source seems ok...

<strong>Site System Access requested for (if different from above):</strong>&nbsp;<esp-condition contenteditable="false" expression="('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star')">Basildon</esp-condition>

Any other suggestions?

Sam

Link to comment
Share on other sites

47 minutes ago, SJEaton said:

@Victor I had 'Basildon' in k and 'INS Star' in o. What may be tricking it is that k may also contain another value as it is a static check box field. Do I need to use Contains 'Basildon' instead of = 'Basildon'? 

@SJEaton Try

'{{.H_custom_k}}' LIKE '%Basildon%'

Link to comment
Share on other sites

4 minutes ago, Graham said:

@SJEaton In addition to @Steve Giller 's question, would you mind posting the expression that you're currently using, please?

 

('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star')

This works if only 1 site is selected in custom k, both not if both i.e if the above example didnt' have Southend or TRAC selected it works ok, but with both selected it doesn't present anything 

Link to comment
Share on other sites

I've got it set up for Southend too but that's exactly the same  

('{{.H_custom_k}}' = 'Southend' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Southend' AND '{{.H_custom_t}}' = 'INR Star')

 

In either instance, if there are 2 things in k it doesn't bring back anything

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...