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

How to split a targetData field by comma

Avatar

Level 1

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:

Gabsulibio_0-1692198931491.png

 

Can someone provide me any insights?

 

Thank you in advance,

Diego

 

 

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @Gabsulibio 

 

Try this:

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

     Manoj
     Find me on LinkedIn

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hello @Gabsulibio 

 

Try this:

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

     Manoj
     Find me on LinkedIn