Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Not in operator for conditional content inside HTML

Avatar

Level 5

Hi there,

 

Is there a way to use not in operator for the below conditional content 

for example if language not in ("EN","FR","ES")

 

<% if (language == "EN" ) { %>
<DIV id=en-version>Hello <%= recipient.firstName %>,</DIV>
<DIV>Discover your new offers!</DIV>
<DIV><a href="https://www.adobe.com/products/en">www.adobe.com/products/en</A></FONT></DIV><%
 } %>
<% if (language == "FR" ) { %>
<DIV id=fr-version>Bonjour <%= recipient.firstName %>,</DIV>
<DIV>Découvrez nos nouvelles offres !</DIV>
<DIV><a href="https://www.adobe.com/products/fr">www.adobe.com/products/fr</A></DIV><%
 } %>
 <% if (language == "ES" ) { %>
<DIV id=es-version><FONT face=Arial>
<DIV>Olà <%= recipient.firstName %>,</DIV>
<DIV>Descubra nuestros nuevas ofertas !</DIV>
<DIV><a href="https://www.adobe.com/products/es">www.adobe.com/products/es</A></DIV>
<% } %>

 

Please suggest

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @rvnth  This will be the correct way

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51';

var featuresArray=features.split(',');

  <%  if ((featuresArray.indexOf(targetData.schema1.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema2.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema3.feat_cd) < 0) &&  !(featuresArray.indexOf(targetData.schema4.feat_cd) < 0))   { %> 

     Manoj
     Find me on LinkedIn

View solution in original post

5 Replies

Avatar

Community Advisor

Hello @rvnth 

 

Yes, You can do it like this.

 

var languagues='ES,FR,EN';
var my_lang='JP'

if(languagues.split(',').indexOf(my_lang) < 0){ //
//print your content here
}

     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ 

Thank you for your reply. If I do not want to use the my_lang variable, can I implement something like the following? I need to test this.

 

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51'

  <%  if (!(targetData.schema1.feat_cd in features) && !(targetData.schema1.feat_cd in features) && !(targetData.schema1.feat_cd in features) &&  !(targetData.schema1.feat_cd in features))   { %> 

 

Avatar

Correct answer by
Community Advisor

Hello @rvnth  This will be the correct way

var features = '21,22,23,24,25,26,27,28,29,30,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51';

var featuresArray=features.split(',');

  <%  if ((featuresArray.indexOf(targetData.schema1.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema2.feat_cd) < 0) && (featuresArray.indexOf(targetData.schema3.feat_cd) < 0) &&  !(featuresArray.indexOf(targetData.schema4.feat_cd) < 0))   { %> 

     Manoj
     Find me on LinkedIn

Avatar

Level 5

Hi @_Manoj_Kumar_ , 

The above code indexOf method === -1 worked for me. 

Avatar

Community Advisor

Hi @rvnth ,

 

You can try this way 

<% if (language == "EN" ) { %>
<DIV id=en-version>Hello <%= recipient.firstName %>,</DIV>
<DIV>Discover your new offers!</DIV>
<DIV><a href="https://www.adobe.com/products/en">www.adobe.com/products/en</A></FONT></DIV><%
} %>
<% else if (language == "FR" ) { %>
<DIV id=fr-version>Bonjour <%= recipient.firstName %>,</DIV>
<DIV>Découvrez nos nouvelles offres !</DIV>
<DIV><a href="https://www.adobe.com/products/fr">www.adobe.com/products/fr</A></DIV><%
} %>
<% else if (language == "ES" ) { %>
<DIV id=es-version><FONT face=Arial>
<DIV>Olà <%= recipient.firstName %>,</DIV>
<DIV>Descubra nuestros nuevas ofertas !</DIV>
<DIV><a href="https://www.adobe.com/products/es">www.adobe.com/products/es</A></DIV>
<% } %>
<% else { %>
Your HTML Content

<% }%>

 

Regards,

Pravallika.