Dynamic code in delivery for multiple values | Community
Skip to main content
Level 2
September 28, 2023
Question

Dynamic code in delivery for multiple values

  • September 28, 2023
  • 3 replies
  • 1298 views

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

 


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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Manoj_Kumar
Community Advisor
Community Advisor
September 28, 2023

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  | https://themartech.pro
Jayan_SkAuthor
Level 2
September 28, 2023

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

 

Marcel_Szimonisz
Community Advisor
Community Advisor
September 28, 2023

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/

Jayan_SkAuthor
Level 2
September 28, 2023

Tried this Code, this is the error I'm getting.

 

 

Marcel_Szimonisz
Community Advisor
Community Advisor
September 28, 2023

Can you look up delivery and screenshot error from dashboard? 

Sukrity_Wadhwa
Community Manager
Community Manager
October 31, 2023

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