Winner needs to be defined from only 2 deliveries in a workflow containing multiple deliveries




I have a workflow that contains multiple email deliveries and I wish to generate a winner email from only 2 deliveries in that workflow.

What change do I need to make in the JS for achieving the same.

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)




Thanks. Change this line:

<condition expr={"@FCP=0 and [@workflow-id]= " +}/>


<condition expr={"@internalName in ('deliveryName1', 'deliveryName2')"}/>

Where deliveryName1, 2 are the internal names of the deliveries (Properties > Internal name).

Answers (2)

Answers (2)



// query the database to find the winner (best open rate)

   var winner = xtk.queryDef.create(

     <queryDef schema="nms:delivery" operation="get">


         <node expr="@id"/>

         <node expr="@label"/>

         <node expr="[@operation-id]"/>



<condition expr={"@FCP=0 and [@workflow-id]= " +}/>



         <node expr="[indicators/@estimatedRecipientOpenRatio]" sortDesc="true"/>




   // create a new delivery object and initialize it by doing a copy of

   // the winner delivery

   var delivery =

   delivery.Duplicate("nms:delivery|" + winner.@id)

    logInfo("Winner: " + winner.@id)

   // append 'final' to the delivery label

   delivery.label = winner.@label + " Final"

   //link the delivery to the operation to make sure it will be displayed in

   // the campaign dashboard. This attribute needs to be set manually here since

   // the Duplicate() method has reset it to its default value => 0

   delivery.operation_id = winner.@["operation-id"]


   // adjust some delivery parameters to make it compatible with the

   // "Prepare and start" option selected in the Delivery tab of this activity

   delivery.scheduling.validationMode = "manual"

   delivery.scheduling.delayed = 0

   // save the delivery in database


   // store the new delivery Id in event variables

   vars.deliveryId =