Loop through linked data in delivery/personalization block

Avatar

Avatar
Validate 1
Level 1
Bowenaus
Level 1

Likes

0 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Bowenaus
Level 1

Likes

0 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
Bowenaus
Level 1

12-11-2020

Hello,

 

We have table which links to the recipients table with a 1 to many relationship (1 recipient may have many records in the 2nd table). We are trying to list data from all linked records in the 2nd table for each recipient. For example, in an email to John Doe we would like a bulleted list of ID1, ID2, ID3, etc. where ID1, ID2, ID3 are the linked records from the 2nd table.

We are wondering:

a) if personalization blocks are capable of handling queries & making API calls or if this is only possible within activities in the workflow via Javascript.

b) If there are any other ideas or solutions anybody has come across which can accomplish this scenario.

 

Here is the code we have tried writing into a personalization block. We see something similar being used from this site, which led us to attempting to use the personalization block approach: https://blog.floriancourgey.com/2018/08/use-querydef-the-database-toolkit-in-adobe-campaign 

var query = NLWS.xtkQueryDef.create(
{queryDef: {schema: "cus:Consumer_Ids", operation: "select",
select: {
node: [{expr: "@company"}, {expr: "@Id"}]
},
where: {
condition: [{expr: "@contactId= '" + recipient.contactId +"'"}]
}
}})

var res = query.ExecuteQuery()

 When attempting to loop through a personalization block, we are receiving this error.: "Error while compiling script. NLWS is not defined." Any insights or ideas are greatly appreciated. Thanks!

 

Austin Bowen

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 250
MVP
DavidKangni
MVP

Likes

260 likes

Total Posts

372 posts

Correct reply

152 solutions
Top badges earned
Boost 250
Validate 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Boost 250
MVP
DavidKangni
MVP

Likes

260 likes

Total Posts

372 posts

Correct reply

152 solutions
Top badges earned
Boost 250
Validate 1
Give Back 5
Give Back 3
Give Back 25
View profile
DavidKangni
MVP

12-11-2020

Hi Austin,

See and example of code below. I used broadLogRcp as it has a 1-N relationship with recipient schema. So for every recipient I want to show all the emails sent

In your case, replace broadLog by the name of your 2nd table.

 

<TABLE>
    <TBODY>
        <TR>
            <TD>Campaign name</TD>
            <TD>Delivery Name</TD>
            <TD>Event Date</TD>
        </TR>
        <%
                for(var i = 0 ; i<recipient.broadLog.length; i++)
                {
                    document.write("<tr>");
                    document.write("<td>" + recipient.broadLog[i].delivery.operation.label + "</td>");
                    document.write("<td>" + recipient.broadLog[i].delivery.label + "</td>");
                    document.write("<td>" + recipient.broadLog[i].eventDate + "</td>");
                    document.write("</tr>");
                }
            %>
        </TR>
    </TBODY>
</TABLE>

 

 

Here is the result

DavidKangni_0-1605233953745.png

Thanks,

David

 

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

181 likes

Total Posts

955 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

181 likes

Total Posts

955 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

17-11-2020

Hi @Bowenaus,

Were you able to resolve this query with the given solution or do you need more help? Do let us know.

Thanks!