Conditional keyword replacement in email body

5.0.4.3

Hi

We want to be able to display different responses based on the value of one of the responses in the body of an email.

Something similar to this:
%response_XXXX_q1^eq:test:%response_XXXX_q2%:%response_XXXX_q3%% (this breaks)

%response_XXXX_q1^eq:test:{%response_XXXX_q2%}:{%response_XXXX_q3%}% (this breaks)

Is this possible in our version?

Appreciate the help
Mitch

Custom form responses are typically values in an array or a JSON object, depending on what type of form field you’re using.

Have you checked the output of %response_XXXX_q1% or checked %globals_post%?

Hi

Yes I can get the values, but when I put the keyword replacements in the conditional it breaks.

I have tried:

The response is: %response_123783_q1%
Is the response test? %response_123783_q1^eq:test:yes %response_123783_q1%:no %response_123783_q1%%
Is the response test? %response_123783_q1^eq:test:yes %globals_response_123783_q1%:no %globals_response_123783_q1%%
Is the response test? %response_123783_q1^eq:test:yes {%globals_response_123783_q1%}:no {%globals_response_123783_q1%}%
Is the response test? %response_123783_q1^eq:test:yes%globals_post_q123783:q1%:no%
Is the response test? %response_123783_q1^eq:test:yes{%globals_post_q123783:q1%}:no%

%globals_post%
%globals_post_q123783:q1%

This is the email:
The response is: test

Is the response test? %response_123783_q1^eq:test:yes test:no test%

Is the response test? yes globals_response_123783_q1%:no %

Is the response test? yes {globals_response_123783_q1%}:no {}%

Is the response test? yesglobals_post_q123783:q1%:no%

Is the response test? yes{globals_post_q123783:q1%}:no%

{ā€œSQ_FORM_123768_PAGEā€:ā€œ1ā€,ā€œform_email_123768_referral_urlā€:"",ā€œq123783:q1ā€:ā€œtestā€,ā€œform_email_123768_submitā€:ā€œSubmitā€}

test

What I would expect is:
Is the response test? yes test
or
Is the response test? no

thanks

Okay. What happens if you try these keywords:

%response_123768_q1^eq:test%
%response_123768_q1^eq:test:{response_123768_q2}:{response_123768_q3}%

1 Like

So we’ve worked it out.

We applied a paint layout to the submission email body:
%form_submission_id^as_asset:asset_contents_paint_layout_id_123456%

And then in the paint layout we can use the conditional:
%begin_question_answer_123321_q1^eq:test%
Question is equal to test. Here is the field
%question_answer_123321_q1%
%else_question_answer_123321_q1^neq:test%
It is not test
%end_question_answer_123321_q1%

Hope that helps.

Mitch

This won’t work as you intend. It’s not a valid keyword sequence.

The ā€˜else’ line should be %else_question%.

Also, does your paint layout apply correctly for emails sent to public users?

Thanks Hugh

Actually no…it doesn’t work for public users we’ve since found out.
Yet to get to the bottom of that.

Okay, if you find out, I’d be interested in the solution. Otherwise, I’d suggest following the solution here: Paint layout in custom form emails

Hi Mitch,

I had a similar discovery a few months ago, with the PL not showing for Public Users.

I instead switched to using globals_contents_raw:123
Where asset #123 is a Standard Page, and then in that standard page I used Conditional Statements to determine what to print.
The Conditional Statements were using globals_post^index keywords - as per the link Hugh gave.

Now I am just trying to work on customising the Subject Line based on what they input… This has been a thorn. Many Keyword Modifiers didn’t seem to work in the Subject Line. Our form is a bit complex because it has 5 fields it needs to read to check if the email is a complaint (from any of the 5 user types). I’m sure a JS code could help me here, in sending a new field POST data that says it IS a complaint or not… :thinking:

Hope this helps,
Emily