Avatar

Level 2

Hi Geoffrey

geoffreyl24045476, Thank you for your response on this.

I tried the above provided Script, however getting an error saying delivery.output.seedList.where[0] is undefined, below is the screenshot for reference getting in Display Logs.

1728709_pastedImage_6.png

Here is the complete code I am trying with:

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

  var winner = xtk.queryDef.create(

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

      <select>

        <node expr="@id"/>

        <node expr="@label"/>

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

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

        <node expr="[scheduling/@contactDate]"/>

        <node expr="[output/seedList/where/condition/@expr]"/>

      </select>

      <where>

        <condition expr={"@FCP=0 and @internalName = 'Em123' and @isModel=0"}/>

      </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)

  // append 'winner' to the delivery label

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

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

  delivery.workflow_id = winner.@["workflow-id"]

  delivery.output.seedList.humanCond = "Query: folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"

  delivery.output.seedList.where.displayFilter = "folder equal to ABC-Seeds or (folder equal to XYZ-Seeds and email of recipient is included in 'email1,email2')"

  delivery.output.seedList.where[0].condition[0].boolOperator = 'AND'; 

  delivery.output.seedList.where[0].condition[0].expr = "[custom_nms_recipient/@email] IN ('xyz123@email.com', 'xyz123@ymail.com')"; 

  delivery.output.seedList.where[0].condition[0].condition[0].boolOperator = 'AND'; 

  delivery.output.seedList.where[0].condition[0].condition[0].condition[0].boolOperator = 'OR'; 

  delivery.output.seedList.where[0].condition[0].condition[0].condition[0].expr = '[folder/@id]=9787930'; 

  delivery.output.seedList.where[0].condition[0].condition[0].condition[1].expr = '[folder/@id]=882531';

  // save the delivery in database

  delivery.save()

  // store the new delivery Id in event variables

  vars.deliveryId = delivery.id

  

// Print Log Details@

  logInfo(vars.deliveryId)

  logInfo(delivery.label)

  logInfo(winner.output.seedList.where.condition.@expr)

Regards,

Mustufa