SJEaton Posted January 19, 2023 Share Posted January 19, 2023 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 More sharing options...
Victor Posted January 19, 2023 Share Posted January 19, 2023 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 More sharing options...
SJEaton Posted January 19, 2023 Author Share Posted January 19, 2023 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 1 Link to comment Share on other sites More sharing options...
Victor Posted January 23, 2023 Share Posted January 23, 2023 @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: 1 Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Thanks @Victor, I'll try it Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 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> <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 More sharing options...
Victor Posted January 24, 2023 Share Posted January 24, 2023 @SJEaton to confirm, do we have the respective values, in those custom fields, for that request? Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 @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'? Link to comment Share on other sites More sharing options...
Met Posted January 24, 2023 Share Posted January 24, 2023 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 More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Hi @Met I've tried both LIKE and CONTAINS and neither have worked if 2 things are selected in custom k. @VictorFor the record, the condition you provided does work if only 'Basildon' is selected in k. Sam Link to comment Share on other sites More sharing options...
Steve Giller Posted January 24, 2023 Share Posted January 24, 2023 @SJEaton What (exactly) is shown in the database for h_custom_k when you select 2 or more answers? Link to comment Share on other sites More sharing options...
Graham Posted January 24, 2023 Share Posted January 24, 2023 @SJEaton In addition to @Steve Giller 's question, would you mind posting the expression that you're currently using, please? Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 2 hours ago, SJEaton said: Excuse my ignorance @Steve Giller, where can I check this? In the request questions it shows as this Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 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 More sharing options...
Steve Giller Posted January 24, 2023 Share Posted January 24, 2023 6 minutes ago, SJEaton said: Excuse my ignorance @Steve Giller, where can I check this? You'll need to use Database Direct to check h_custom_k in the h_itsm_requests table using the relevant Request's Reference for h_pk_reference, although from the screenshot it's likely to be a comma-separated list. Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Eek I'm struggling to do this @Steve Giller , useless on database direct I'm afraid. Can you provide what I need to enter to find this please? Link to comment Share on other sites More sharing options...
Steve Giller Posted January 24, 2023 Share Posted January 24, 2023 SELECT h_pk_reference, h_custom_k, h_custom_o, h_custom_t FROM h_itsm_requests WHERE h_pk_reference = '[REQ_REFERENCE]' should get the fields we're interested in. 1 Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 @Steve Giller sorry that was the wrong request ref but you get the gist and yes it is separated by a coma. Link to comment Share on other sites More sharing options...
Steve Giller Posted January 24, 2023 Share Posted January 24, 2023 @SJEaton Just as a sanity check - the last few posts have not included any mention of Basildon, and that's required to make the ESP condition work ... Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 This is the correct request Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 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 More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Here's once I just submitted. The email didn't pull through anything. Link to comment Share on other sites More sharing options...
Steve Giller Posted January 24, 2023 Share Posted January 24, 2023 Can you paste the <esp-condition>...</esp-condition> from the Template as it is now, please? Again, just as a sanity check, please double-check the send email node is set to use the expected Template. Link to comment Share on other sites More sharing options...
SJEaton Posted January 24, 2023 Author Share Posted January 24, 2023 Yes it uses the correct template. ESP Condition... ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_o}}' = 'INR Star') OR ('{{.H_custom_k}}' = 'Basildon' AND '{{.H_custom_t}}' = 'INR Star') Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now