Expand my Community achievements bar.

Join us for Adobe Campaign Community Q&A Coffee Break on Thursday, March 7th at 8am PT with Eric Perrin, Gael Mouello, Chakravarthy Kalva, Bruce Swann and Sandra Hausmann.
SOLVED

how to check option condition in email template script

Avatar

Level 2

Hi team,

I have to check if the option value is 0 my email template prints "Hi" and if the option value is 1 it prints "Bye". this scenario I want to be achieve in an email template not using a Personalization block.

My code below:

<%
var A = "<%@ include option='test' %>

if (A == '0')
{

<p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">hi</span></b></p>

}
else
{
<p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">bye</span></b></p>
}

%>

 

error:

01/18/2024 3:00:53 AM Failed Unreachable xxx Error while compiling script 'content htmlContent' line 8: illegal XML character (line='var A = <%@ include option='test' %>;\ ' token='%@ include option='test' %>;\ '). SCR-160032 Javascript&colon; error while compiling script 'content htmlContent'. JST-310007 Unable to compile script (content htmlContent).

 

@ParthaSarathy  please help on this 

 

 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Kumar_27 ,

 

Please try by adding the below code in the Script Tab of your Reccuring Delivery 

var test="";

if(getOption("yourOptionName") == 0)
{
test=0;
}


logInfo("test var value"+test)

 

and in your Reccuring delivery , Please use the below code snippet

 

<% if(test = '0' ) { %><p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">hi</span></b></p><% }
else { %><p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">bye</span></b></p><% } %>

 

Regards,

Pravallika.

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @Kumar_27 

 

Could you try defining the variables [var A = <%@ include option='test' %>]under the script tag <script> ..... </script>  in your HTML code and use the below code in your body tag.

<%
if (A == '0')
{
%>
<p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">hi</span></b></p>
<%
}
else
{ %>
<p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">bye</span></b></p>
<%
}
%>

 

Thanks,

Akshay

Avatar

Level 2

hi @AkshayAnand 

 

 I got the below error while I tried the above method. 

 

Error while compiling script 'content htmlContent' line 7: A is not defined. SCR-160012 Javascript&colon; error while evaluating script 'content htmlContent'.

Avatar

Correct answer by
Community Advisor

Hi @Kumar_27 ,

 

Please try by adding the below code in the Script Tab of your Reccuring Delivery 

var test="";

if(getOption("yourOptionName") == 0)
{
test=0;
}


logInfo("test var value"+test)

 

and in your Reccuring delivery , Please use the below code snippet

 

<% if(test = '0' ) { %><p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">hi</span></b></p><% }
else { %><p><b><span style="font-family: 'Times New Roman'; font-size: 16px;">bye</span></b></p><% } %>

 

Regards,

Pravallika.