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.
facilityId | Name | Addr1 | Addr2 | Phone | managerCode | rcpManager | |
123 | Joe's Garage | Lorem | Dolor | joe@garage.com | 12345 | 5 | manager@adobe.com |
456 | Car Express | Ipsum | Sit Amet | car@express.com | 6778 | 5 | manager@adobe.com |
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?
Solved! Go to Solution.
Views
Replies
Total Likes
@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.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
What is the schema structure? It is possible to share the screenshot of targeting dimension and targetData?
Views
Replies
Total Likes
This is what I gathered from the query transition (after deduplication).
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.
Views
Replies
Total Likes
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>
<%}%>
Views
Replies
Total Likes
I tried
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>
Here is the result of the transition data
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.
Views
Replies
Total Likes
Anyone? this should be a basic thing to do, I doubt im the only one facing this issue?
Views
Replies
Total Likes
@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.