Hi Experts,
I have requirement to update Tracking Type to the URLs in Email HTML, for around 300 the email deliveries.
I checked in the delivery the tracking is Enabled, the value is "0"[Zero] or other values.
Now I want to update with Value as"1" [Not tracked].
So, anyone can help me on this.
Thank you.
Solved! Go to Solution.
Views
Replies
Total Likes
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
Hello @iSantoshk
if these are delivery templates then you can select all and then perform a mass update.
Here is a documentation on how to use this feature: https://experienceleague.adobe.com/en/docs/campaign-classic/using/getting-started/profile-management...
Views
Replies
Total Likes
Hi @_Manoj_Kumar_,
Thanks for your reply.
But I want to update the each URL in HTML content under each delivery.
Like, I want to update the node of delivery.content.html.urlConfig.url.@trackingType. under each delivery HTML content.
attaching screenshot for reference.
Thank you.
Views
Replies
Total Likes
Hi @_Manoj_Kumar_ ,
I have tried with below JS code, but getting error. sharing the details.
JS Code:
// template IDs
var templateIds = []; // Replace with actual template IDs
// New tracking type
var newTrackingType = '1';
var query = xtk.queryDef.create(
<queryDef schema="nms:delivery" operation ="select">
<select>
<node expr="@internalName"/>
</select>
<where>
<condition expr="@internalName = 'DM16'"/>
</where>
</queryDef>);
var tResult = query.ExecuteQuery();
var tCount = tResult.delivery.length();
logInfo("TCount:"+ tCount);
var calltArray = tArray();
function tArray(){
for(var i=0; i<tCount; i++)
{
templateIds.push(tResult[i].@internalName);
}
logInfo("templateIds: " + templateIds);
return;
}
// Function to update the trackingType attribute under content.html.urlConfig.url node for a single email template
function updateTrackingTypeForEmailTemplate(templateId, newTrackingType) {
// Fetch the email template XML content
var template = NLWS.nmsDelivery.load(templateId); // Assume NLWS object is available for SOAP API calls
var templateXml = template.toXML();
// Update trackingType attribute in the email template XML content
var updatedXmlTemplate = updateTrackingTypeInEmailTemplate(templateXml, newTrackingType);
// Update the email template XML content
templateXml.@xtkschema = "nms:delivery"; //Add the schema, needed for xtk.session.Write
templateXml.@_operation = "update";
NLWS.xtkSession.Write(template); // Save the updated template
}
// Function to update the trackingType attribute under content.html.urlConfig.url node for multiple email templates
function updateTrackingTypeForMultipleEmailTemplates(templateIds, newTrackingType) {
templateIds.forEach(function(templateId) {
updateTrackingTypeForEmailTemplate(templateId, newTrackingType);
});
console.log('Tracking type updated for all email templates.');
}
// Function to update the trackingType attribute under content.html.urlConfig.url node in the email template XML content
function updateTrackingTypeInEmailTemplate(xmlContent, newTrackingType) {
// Parse the XML content
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlContent, 'text/xml');
// Find all url nodes under content.html.urlConfig
var urlNodes = xmlDoc.querySelectorAll('content > html > urlConfig > url');
// Update trackingType attribute for each url node
urlNodes.forEach(function(urlNode) {
urlNode.setAttribute('trackingType', newTrackingType);
});
// Serialize the updated XML content back to string
var updatedXmlContent = new XMLSerializer().serializeToString(xmlDoc);
return updatedXmlContent;
}
// Update trackingType for multiple email templates
updateTrackingTypeForMultipleEmailTemplates(templateIds, newTrackingType);
Error:
Thank you
Views
Replies
Total Likes
Hello @iSantoshk
You will have to pass the template primary key not the internal name.
The error says that DM16 is not an integer value.
change this line
templateIds.push(tResult[i].@internalName);
with this
templateIds.push(tResult[i].@id);
Views
Replies
Total Likes
Hi @_Manoj_Kumar_ ,
Thanks for your time on this case. Its really appreciated.
I have updated to [@id] now.
If can review my Functions in above code, I am getting error, DOMParser is not defined.
its created generic way of Javascript.
But my question is, how to access delivery content any nodes, such as urls, title, label, what is the adobe campaign classic, methods and objects.
I seen, some of example to access url nodes, like delivery.content.html.urlConfig.url[i].source.
for the same can we do it for delivery.content.html.urlConfig.url[i].trackingType?
Please help to share the same code to access it and update it.
Thank you.
Views
Replies
Total Likes
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
Views
Likes
Replies
Views
Likes
Replies