In this example, we want to send an alert to an operator that will contain the name of profiles who opened a newsletter but did not click the link it contains.
The profiles’ first and last name fields are linked to the Recipients targeting dimension, whereas the Alert activity is linked to the Operator targeting dimension. As a result, there is no field available between the two targeting dimensions to perform a reconciliation and retrieve the first and last name fields, and display them in the Alert activity.
The process is to build a workflow as below:
Add the code below into the JavaScript code activity.
var query = xtk.queryDef.create(
<queryDef schema="temp:query" operation="select">
<select>
<node expr="[target/recipient.@firstName]"/>
<node expr="[target/recipient.@lastName]"/>
</select>
</queryDef>
);
var items = query.ExecuteQuery();
Make sure that the Javascript code corresponds to your workflow information:
To retrieve these information, follow the steps below:
Right-click the outbound transition from the Query activity, then select Display the target.
Right-click the list, then select Configure list.
The query targeting dimension and fields names display in the list.
Add the code below into the Test activity to check if the targeted population contains at least 1 profile.
var.recCount>0
Now that the population has been added into the instance variable with the desired fields, you can add these information into the Alert activity.
To do this, add into the Source tab the code below:
<ul>
<%
var items = new XML(instance.vars.items)
for each (var item in items){
%>
<li><%= item.target.@firstName %> <%= item.target.@lastName %></li>
<%
} %></ul>
The <%= item.target.recipient.@fieldName %> command lets you add one of the fields that have been saved to the instance variable through the JavaScript code activity.
You can add as many fields as desired, as long as they have been inserted into the JavaScript code.