Hi Team,
I am writing a script to mass update parameters such as Sender Address and Reply Address from the Deliveries schema. Additionally, I need to update the Routing (External Account) of Delivery Templates, but I'm unable to do so as the value does not get updated when using the Routing Primary Key.
Moreover, I want to exclude OOTB Delivery Templates to ensure they are not modified or updated.
Below is the script I am using:
var delivery = NLWS.xtkQueryDef.create
(
{queryDef: {schema: vars.targetSchema , operation: 'select',
select:
{
node: [
{expr: '@id'},
{expr: '@from'},
{expr: '@reply'},
{expr: '@extAcct'},
]
}
}});
var results = delivery.ExecuteQuery();
for each (var res in results.getElements("query"))
{
delivery = NLWS.nmsDelivery.load(res.getAttribute('id'));
delivery.mailParameters.senderAddress= res.getAttribute('from');
delivery.mailParameters.replyAddress= res.getAttribute('reply');
delivery.deliveryProvider.id= res.getAttribute('extAcct');
delivery.save();
}
Updating the Routing (External Account) in Delivery Templates – The value is not getting updated.
Excluding OOTB Delivery Templates – How can I filter them out to avoid unintended modifications?
Any guidance on these points would be greatly appreciated.
Thanks,
Ankita Vishe
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @AnkitaVi1 ,
The issue you're encountering—where the deliveryProvider.id (Routing/External Account) isn’t updating—likely stems from how Adobe Campaign handles the deliveryProvider field. In the nms:delivery schema, deliveryProvider is a link to the xtk:provider schema (or nms:externalAccount in some contexts), and you need to set it using the correct foreign key reference. Simply assigning res.getAttribute('extAcct') to delivery.deliveryProvider.id may not work as expected because deliveryProvider is an object, not a direct field.
To update the Routing correctly:
Maybe you can try the below JS.
// Define the query to select delivery templates
var deliveryQuery = NLWS.xtkQueryDef.create(
{
queryDef: {
schema: "nms:delivery",
operation: "select",
select: {
node: [
{ expr: "@id" },
{ expr: "@from" },
{ expr: "@reply" },
{ expr: "@extAcct" },
{ expr: "@namespace" },
{ expr: "@internalName" }
]
},
where: {
condition: [
{ expr: "[@namespace] != 'nms'" }, // Exclude OOTB templates
{ expr: "[@isModel] = 1" } // Target templates only
]
}
}
}
);
// Execute the query
var results = deliveryQuery.ExecuteQuery();
// Loop through results
for each (var res in results)
{
var delivery = NLWS.nmsDelivery.load(res.@id.toString());
// Update sender and reply addresses
delivery.mailParameters.senderAddress = res.@from.toString();
delivery.mailParameters.replyAddress = res.@reply.toString();
// Update Routing (External Account)
if (res.@extAcct.toString() != "")
{
delivery.deliveryProvider = { id: res.@extAcct.toString() };
}
// Save the delivery
try {
delivery.save();
logInfo("Updated delivery: " + res.@id.toString());
} catch (e) {
logError("Failed to update delivery " + res.@id.toString() + ": " + e);
}
}
Thanks
Sushant Trimukhe
Views
Replies
Total Likes
Hi @AnkitaVi1 ,
The issue you're encountering—where the deliveryProvider.id (Routing/External Account) isn’t updating—likely stems from how Adobe Campaign handles the deliveryProvider field. In the nms:delivery schema, deliveryProvider is a link to the xtk:provider schema (or nms:externalAccount in some contexts), and you need to set it using the correct foreign key reference. Simply assigning res.getAttribute('extAcct') to delivery.deliveryProvider.id may not work as expected because deliveryProvider is an object, not a direct field.
To update the Routing correctly:
Maybe you can try the below JS.
// Define the query to select delivery templates
var deliveryQuery = NLWS.xtkQueryDef.create(
{
queryDef: {
schema: "nms:delivery",
operation: "select",
select: {
node: [
{ expr: "@id" },
{ expr: "@from" },
{ expr: "@reply" },
{ expr: "@extAcct" },
{ expr: "@namespace" },
{ expr: "@internalName" }
]
},
where: {
condition: [
{ expr: "[@namespace] != 'nms'" }, // Exclude OOTB templates
{ expr: "[@isModel] = 1" } // Target templates only
]
}
}
}
);
// Execute the query
var results = deliveryQuery.ExecuteQuery();
// Loop through results
for each (var res in results)
{
var delivery = NLWS.nmsDelivery.load(res.@id.toString());
// Update sender and reply addresses
delivery.mailParameters.senderAddress = res.@from.toString();
delivery.mailParameters.replyAddress = res.@reply.toString();
// Update Routing (External Account)
if (res.@extAcct.toString() != "")
{
delivery.deliveryProvider = { id: res.@extAcct.toString() };
}
// Save the delivery
try {
delivery.save();
logInfo("Updated delivery: " + res.@id.toString());
} catch (e) {
logError("Failed to update delivery " + res.@id.toString() + ": " + e);
}
}
Thanks
Sushant Trimukhe
Views
Replies
Total Likes
Use a query activity to get your deliveries which need to be updated and follow this
Thanks,
David
Hi @AnkitaVi1,
Were you able to resolve this query with the help of the provided solutions, or do you still need further assistance? Please let us know. If any of the answers were helpful in moving you closer to a resolution, even partially, we encourage you to mark the one that helped the most as the 'Correct Reply.'
Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies