Using Javascript for 'for loop' in campaign standard | Community
Skip to main content
Level 2
Sep 16, 2021 11:40 AM UTC
Solved

Using Javascript for 'for loop' in campaign standard

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SatheeskannaK
SatheeskannaKAccepted solution
Level 1
Sep 16, 2021 1:48 PM UTC

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

2 replies

acc_acs
Level 3
Oct 4, 2021 9:54 AM UTC

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-externalapi-to-call-the-quot-azure-logic-apps-quot/idi-p/417734

 

Regards

Paulo

Translate
SatheeskannaK
SatheeskannaKAccepted solution
Level 1
Sep 16, 2021 1:48 PM UTC

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!

Translate
Thanks, Sathees