Use current campaign name in typology rule
Hello everyone,
currently I am trying to create a typology rule which makes sure that a recipient does not get the same Email-campaign twice.
It seems that I have to use JavaScript to retrieve the campaign name from where the delivery is startet.
I thought maybe something like this could work:
// Define campaign name of current workflow where delivery is located.
function currentCampaignName(){
// Get primary key from workflow.
var workflowID = instance.id;
var tmpCon = application.getConnection();
var internalName = tmpCon.query("SELECT O1.sInternalName FROM XtkWorkflow W0 JOIN NmsOperation O1 ON (O1.iOperationId = W0.iOperationId) WHERE W0.iWorkflowId = $(l)",workflowID);
for each(var row in internalName)
var campaignName = row[0];
return campaignName;
}// Exclude recipients which got the defined campaign within last 60 days.
function excludeRecipients (){
var tmpCon = application.getConnection();
var campaignName_compare = currentCampaignName();
// Select all delivery logs of recipient from current campaign.
var broadLog_array = tmpCon.query("SELECT COUNT(B0.iBroadLogId) FROM NmsBroadLogRcp B0 JOIN NmsDelivery D1 ON (D1.iDeliveryId = B0.iDeliveryId) JOIN NmsOperation O2 ON (O2.iOperationId = D1.iOperationId) WHERE O2.sInternalName = $(sz)", campaignName_compare);
for each(var row in broadLog_array)
var countBroadLog = row[0];
if(countBroadLog > 0) {
return false;
} else {
return true;
}
}
return excludeRecipients();
It works if I put it within a JavaScript component of a workflow but within a typologie rule I get the following error:

Since "instance" is apparently not available within a delivery what should I use instead to get the campaign name?
Or do you have a better solution at hand?
Best,
Bella