How to split a targetData field by comma | Community
Skip to main content
Gabsulibio
August 16, 2023
Solved

How to split a targetData field by comma

  • August 16, 2023
  • 1 reply
  • 1125 views

Hi,

 

I have a column (Products) coming from a read list activity containing all the products purchased by a customer, separated by comma. I want to add each product in a bullet point, so I'm trying to split this targetData field and then create a for each. This is the code I'm using in the html:

 

<ul>
<% var p = targetData.Products.split(","); %>
<% for each (var products in p){ %>
<li><%= products %></li>
<% } %>
</ul>

 

Unfortunately I get the following error:

 

Can someone provide me any insights?

 

Thank you in advance,

Diego

 

 

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

Hello @gabsulibio 

 

Try this:

<ul> <% var p1 = targetData.Products; var p=p1.split(","); %> <% for each (var products in p){ %> <li><%= products %></li> <% } %> </ul>

1 reply

Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
August 17, 2023

Hello @gabsulibio 

 

Try this:

<ul> <% var p1 = targetData.Products; var p=p1.split(","); %> <% for each (var products in p){ %> <li><%= products %></li> <% } %> </ul>
Manoj  | https://themartech.pro
Gabsulibio
August 17, 2023

Thank you @_manoj_kumar_ 

It's working!