Hi @isantoshk,
You can do something like this:
var delivery = nms.delivery.load(1234);
var urls = delivery.content.html.urlConfig.url.length;
//looping through all URLs in urlConfig
for (var i = 0; i < urls; i++){
delivery.content.html.urlConfig.url[i].trackingType = 1;
}
delivery.save();
BR,
Ishan
Hi @isahore ,
Thank you for your time, its really appreciated.
Its WORKING now.
Here the my updated Code for multiple Delivery templates update.
// Definign Empty Array for Delivery Templates Ids
var templateIds = [];
//creating Query to get Delivery templateIds
var query = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation ="select">
<select>
<node expr="@id"/> // selecting Primary Keys from Delivery Schema
</select>
<where>
<condition expr="@internalName LIKE '%DM%'" bool-operator="AND"/>
<condition expr="@messageType = '0'"/> // checking only Email Channel Deliveries and more conditions based on your requirment.
</where>
<orderBy>
<node expr="@id" sortDesc="true"/> // we can orderBy based your requirment using expr value.
</orderBy>
</queryDef>);
var tResult = query.ExecuteQuery();
var tCount = tResult.delivery.length();
logInfo("Templates Count:"+ tCount);
var calltArray = tArray(); // Caling Fucntion for Create TemplateIDs Array with delivery @Ids
// defining Function for creating Array
function tArray(){
//Looping all the Delivery Ids
for(var i=0; i<tCount; i++)
{
templateIds.push(parseInt(tResult[i].@id));
}
logInfo("templateIds: " + templateIds);
return;
}
//looping through all Delivery in TemplateIds
for (var j = 0; j < templateIds.length; j++){
var delivery = nms.delivery.load(templateIds[j]);
var urls = delivery.content.html.urlConfig.url.length;
logInfo("URLs Count: " + urls );
//looping through all URLs in urlConfig
for (var k= 0; k < urls; k++){
//logInfo("TrackingTye before Update " + delivery.content.html.urlConfig.url[k].trackingType);
if(delivery.content.html.urlConfig.url[k].trackingType === 0) // accessing only Enabled Traking Type URLs with value "1"
{
var updatedTType = delivery.content.html.urlConfig.url[k].trackingType = 1; // updating as Not Tracked with value "1"
}
}
delivery.save();
logInfo( "TrackingTye after Update " + updatedTType);
}
logInfo("Tracking type updated for " +tCount+ " all email templates");
Thank you,
Santosh