Create a list programatically and insert reciepients info into it
I've used a JS activity to query the recipients, and also extract the IDs.
I need to to this to apply some logic to sort them randomly, and apply some other logic to them. (After that, I need to split those in halfs and save them into different lists), in order to them to them different emails, sms, or pushs.
So how to create a list using JS, let's calle it "my_list" and then insert the recipients into it?
var query = NLWS.xtkQueryDef.create(
<queryDef schema={"nms:recipient"} operation="select" lineCount="999999999">
<select>
<node expr="@id"/>
</select>
</queryDef>
);
var res = query.ExecuteQuery();
var recipients = res.getElementsByTagName("recipient")
var allRecipients = [];
for each (var r in recipients)
//logInfo(r.getAttribute("id"))
allRecipients.push(r.getAttribute("id"))
// Mezclar el array aleatoriamente para el A/B testing
allRecipients.sort(function() { return 0.5 - Math.random() });.

