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

Rishabh46

05-02-2019

Hi,

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)

wodnicki

MVP

07-02-2019

Thanks. Change this line:

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

To:

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

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

Answers (2)

Answers (2)

Rishabh46

07-02-2019

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

   var winner = xtk.queryDef.create(

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

       <select>

         <node expr="@id"/>

         <node expr="@label"/>

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

       </select>

       <where>

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

       </where>

       <orderBy>

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

       </orderBy>

     </queryDef>).ExecuteQuery()

  

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

   // the winner delivery

   var delivery = nms.delivery.create()

   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

   delivery.save()

 

   // store the new delivery Id in event variables

   vars.deliveryId = delivery.id