Expand my Community achievements bar.

SOLVED

Using Javascript for 'for loop' in campaign standard

Avatar

Level 2

Hey

 

I need to use a for loop to loop through a csv file where someone can have multiple streaming subscriptions. For this I used javascript (code below) in my delivery via legacy editor, but when I save my delivery and go back to check the code it has jumped.

 

This is my code:

<table>

<tr>
<td>Name</td>
<td>Subscription</td>
<td>Cost</td>
<td>Has App?</td>
</tr>
<% for (var i=0; i<targetData.fileImport.length; i++) {%>
<tr>
<td><% =targetData.fileImport[i].streamingName%></td>
<td><% =targetData.fileImport[i].monthlySubscription %></td>
<td><% =targetData.fileImport[i].monthlyCost %></td>
<td><% =targetData.fileImport[i].hasApp%></td>
</tr> <%}%>

</table>

 

And this is wat campaign makes of it:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body style="" class="">
<% for (var i=0; i<targetData.fileImport.length; i++) {%><%}%>
<table>
<tbody>
<tr>
<td>Name</td>
<td>Subscription</td>
<td>Cost</td>
<td>Has App?</td>
</tr>
<tr>
<td><% =targetData.fileImport[i].streamingName%></td>
<td><% =targetData.fileImport[i].monthlySubscription %></td>
<td><% =targetData.fileImport[i].monthlyCost %></td>
<td><% =targetData.fileImport[i].hasApp%></td>
</tr>
</tbody>
</table>
</body>
</html>

 

So the opening of my javascript code gets pushed up in the code for no reason. Does someone have a solution or knows how I can implement javascript in a delivery in campaign standard? Because now I get an error in my workflow because of my delivery.

 

Thank you.

 

Lara

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @siljkla,

 

Java script is not supported on ACS but still many use them with their own risk of when there's an update to the system it may vanish the code you have.

Looking at your code you will have to use personalization variables based on upstream data provided by workflow when you link profile to get subscription details. Let me know if i understood your ask in different way.

 

Thanks!

Thanks, Sathees

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @siljkla,

 

Java script is not supported on ACS but still many use them with their own risk of when there's an update to the system it may vanish the code you have.

Looking at your code you will have to use personalization variables based on upstream data provided by workflow when you link profile to get subscription details. Let me know if i understood your ask in different way.

 

Thanks!

Thanks, Sathees

Avatar

Level 5

Hi @siljkla ,

 

In this case, when I need use code to complex recursisvity processing, I'm using to "External API" to call a external service and there I can use javascript or another code language to processing my code.

 

See this link: https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-standard-ideas/acs-using-the-externa...

 

Regards

Paulo