Expand my Community achievements bar.

We are excited to introduce our latest innovation to enhance the Adobe Campaign user experience — the Adobe Campaign v8 Web User Interface!

Email Loop in ACS

Avatar

Level 3
Level 3

I have a query resulting in multiple lines that I need to display in an email to then send it to the rcpManager which is the profile I need to send the email to.

 

facilityIdNameAddr1Addr2EmailPhonemanagerCodercpManager
123Joe's GarageLoremDolorjoe@garage.com123455manager@adobe.com
456Car ExpressIpsumSit Ametcar@express.com67785manager@adobe.com

 

o_X_0-1712159987558.png

Now, I need to display these in an email using a loop, but it doesnt seem to work for me?

 

 

 

 

 

<% for (var i =0;i<=context.targetData.length;i++) { %>
<!---somehtml tables and columns here--->
   <%= context.targetData[i].facilityId%> </span>
   <%= context.targetData[i].name%> </span>
   <%= context.targetData[i].Addr1%> </span>

<%}%>

 

 

 

If I try to get the length of targetData it comes back as undefined

`<%= context.targetData.length %>` --> undefined

 

If I get the length of facilityId its fine.so how do I iterate through all the rows?

 

`<%= context.targetData.facilityId.length %>` --> 8

 

 

What would be the correct way?

@SatheeskannaK 

 

 
 

 

 

8 Replies

Avatar

Community Advisor

Hello @o_X 

 

What do you get when you print this?

<%= context.targetData.facility.length %>


     Manoj
     Find me on LinkedIn

Avatar

Level 3
Level 3

I get the length of the facilityid value in integer, the template seems to only just fetch a random record out of the two that I want to iterate.

 

8

Avatar

Community Advisor

What is the schema structure? It is possible to share the screenshot of targeting dimension and targetData?


     Manoj
     Find me on LinkedIn

Avatar

Level 3
Level 3

This is what I gathered from the query transition (after deduplication).

o_X_0-1712193714916.png

o_X_1-1712193789432.png

 

o_X_2-1712193910343.png

 

The query has a link to an many table returning a single record collection and link to another 0:1 to get some more data.

o_X_3-1712194051182.png

 

 

 

Avatar

Community Advisor

Hello @o_X 

 

Bringing data from 1:N link to targetData will only bring any one record.

 

Did you try something like this?

 

 

<% for (var i =0;i<=context.targetData.nacmemberfacilitynacFacilityLink.length;i++) { %>
<!---somehtml tables and columns here--->
   <%= context.targetData.nacmemberfacilitynacFacilityLink[i].facilityId%> </span>
   <%= context.targetData.nacmemberfacilitynacFacilityLink[i].name%> </span>
   <%= context.targetData.nacmemberfacilitynacFacilityLink[i].Addr1%> </span>

<%}%>

     Manoj
     Find me on LinkedIn

Avatar

Level 3
Level 3

I tried

o_X_0-1712213900199.png

and the length comes up as undefined, it should come up at least with the index 0 its so weird

 

I then removed all additional data to N collections, and still the length of targetData is undefined

 

 

<!DOCTYPE html>
<html>
  <head>
  </head>
<body style="" class="">
<%= context.targetData.length %>
<%= context.targetData.facilityName %>
</body>

</html>

 

o_X_1-1712215482157.png

o_X_0-1712215686204.png

o_X_1-1712215708450.png

 

Here is the result of the transition data

o_X_2-1712215788162.png

 

the length of targetData is still undefined, but if I do `context.targetData.faciliyName.length` then it returns something, i would have thought it would return at least the index value 0 or 1.

 

Avatar

Level 3
Level 3

Anyone? this should be a basic thing to do, I doubt im the only one facing this issue?

Avatar

Community Advisor

@o_X, You will not be able to get the length of the link rather it will work on the additional data field. You can correlate this with the visibility condition, If you look at the visibility condition to display the structure component it will work on the field level.

Thanks, Sathees