Disable the creation of a Campaign Delivery if the Campaign has already finished | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

Hi @campaignerforlife ,

Create a Typology rule under /Administration/Campaign Management/Typology management/Typology rules/

And select the type as 'Control' and configure as below

In code tab, add the below script:

var internalName = delivery.internalName; var query = xtk.queryDef.create(<queryDef operation="select" schema="nms:delivery"> <select> <node expr="@internalName"/> <node expr="@id"/> <node expr="@created"/> <node expr="[operation/@id]"/> <node expr="[operation/@end]"/> </select> <where> <condition expr={"@internalName = '"+internalName+"'"}/> </where> </queryDef>); var record = query.ExecuteQuery(); for each (var variable in record) { var campaignEndDate = variable.operation.@end; var deliveryCreationDate = formatDate(variable.@created, "%4Y-%2M-%2D"); if( deliveryCreationDate > campaignEndDate) { logWarning("Delivery Creation Date crossed campaign End Date"); return false; } else{ return true; } }

And create a new 'Typology' and add the above created typology rule in it.

 

When creating a campaign delivery, use this typology in delivery property.

Now if the Delivery creation date is greater than campaign end date, then the delivery gets failed with the Audit log as 'Delivery Creation Date crossed campaign End Date'

 

 

 

1 reply

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
July 26, 2023

Hi @campaignerforlife ,

Create a Typology rule under /Administration/Campaign Management/Typology management/Typology rules/

And select the type as 'Control' and configure as below

In code tab, add the below script:

var internalName = delivery.internalName; var query = xtk.queryDef.create(<queryDef operation="select" schema="nms:delivery"> <select> <node expr="@internalName"/> <node expr="@id"/> <node expr="@created"/> <node expr="[operation/@id]"/> <node expr="[operation/@end]"/> </select> <where> <condition expr={"@internalName = '"+internalName+"'"}/> </where> </queryDef>); var record = query.ExecuteQuery(); for each (var variable in record) { var campaignEndDate = variable.operation.@end; var deliveryCreationDate = formatDate(variable.@created, "%4Y-%2M-%2D"); if( deliveryCreationDate > campaignEndDate) { logWarning("Delivery Creation Date crossed campaign End Date"); return false; } else{ return true; } }

And create a new 'Typology' and add the above created typology rule in it.

 

When creating a campaign delivery, use this typology in delivery property.

Now if the Delivery creation date is greater than campaign end date, then the delivery gets failed with the Audit log as 'Delivery Creation Date crossed campaign End Date'

 

 

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
CampaignerForLife
Level 5
July 26, 2023

This perfectly worked, thank you very much!! you're the best @parthasarathy