Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!

Dynamic code in delivery for multiple values

Avatar

Level 2

I don't know the proper way to handle dynamic code with multipe values. Can someone help me?

Jayan_Sk_0-1695879936010.png

 


This is the error I am facing when I use switch case in the delivery.
i have attached the code and th error screenshot below.

6 Replies

Avatar

Community Advisor

Hello @Jayan_Sk 

 

You can use the If else condition.

 

Here is an example:

<% if(targetData.productType=='cavity'){ %>

INCLUDE CAVITY VIEW HERE

<% }  if(targetData.productType=='PRODUCT_2'){ %>
INCLUDE PRODUCT 2 VIew HERE

<% } %>

     Manoj
     Find me on LinkedIn

Avatar

Level 2

This one is working. But I have 4 cases so I thought of using switch case.

 

Avatar

Community Advisor

Hello @Jayan_Sk ,

Maybe you can try apart from IF that worked:

  • can you try to cast targetData to string. 

 

targetData.productType.toString()

 

  • can you try case swith and save the view as variable and then use it in include view?

 

<%
var viewName = ""
switch(targetData.productType.toString()){
   case "whitening":
     viewName = "orn_VIEW84"
   break;
   case "sensitive":
     viewName = "orn_VIEW114"
   break;
}
%>
<%@ inlcude view={viewName} %>

 

 

Marcel Szimonisz

MarTech Consultant
for more tips visit my blog
https://www.martechnotes.com/

Avatar

Community Advisor

Can you look up delivery and screenshot error from dashboard? 

Avatar

Administrator

Hi @Jayan_Sk,

Were you able to resolve this query with the help of the given solutions or do you still need help here? Do let us know. 
Thanks!



Sukrity Wadhwa