Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Second Highest Winning Delivery Needs to be Deployed

mustufam5967803
Level 2
Level 2

Hi Team,

I have a condition where I have four Deliveries and I need to deploy to the Second highest Open rate delivery.

The logic I am using is : A/B testing

Can you help me with the JS code that will pick the second winining delivery based on Open rate.

Thanks in Advance!

[ duplicate thread ] --> Second Highest Winning Delivery Needs to be Deployed

1 Accepted Solution
wodnicki
Correct answer by
Community Advisor
Community Advisor

You didn't select @internalName in the query. Use a simple counter here:

var winner, i = 1;

for each (var row in res) {

    if (i++ === 2) winner = row;

}

View solution in original post

7 Replies
try67
Level 4
Level 4

You posted your question in the Acrobat JavaScript forum. I moved it for you to the Adobe Campaign Classic forum.

mustufam5967803
Level 2
Level 2

Thank you, try67

My question is for Adobe Campaign, could you please forward it to campaign experts for speedy answer.

wodnicki
Community Advisor
Community Advisor

Hi,

Change the js so instead of operation="get" it's operation="select", for:

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

  var winner = xtk.queryDef.create(

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

Then iterate over the results, stopping at the second row.

Thanks,

-Jon

mustufam5967803
Level 2
Level 2

Hi Wodnicki,

Can you help me withe the code to iterate the result and stop at second row.

I tried with For Each loop but getting some error.

Regards,

Mustufa

wodnicki
Community Advisor
Community Advisor

Could you paste your code that's failing, with the error?

mustufam5967803
Level 2
Level 2

Hi Wodnicki,

The code I  am using is as follows:

  var winner = xtk.queryDef.create(

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

       <select>

         <node expr="@id"/>

         <node expr="@label"/>

     <node expr="@internalName"/>

       </select>

       <where>

        <condition expr={"@FCP=0 and [@internalName] in ('em123','em124','em125','em126') and @isModel=0"}/>

       </where>

       <orderBy>

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

       </orderBy>

     </queryDef>)

    res = winner.ExecuteQuery();

   

for each (var row in res)

{

     logInfo(row.@internalName)

     }

I tried reading the rows through for each, not getting the seond highest delivery internal name though, please help ASAP.

Regards,

Mustufa

wodnicki
Correct answer by
Community Advisor
Community Advisor

You didn't select @internalName in the query. Use a simple counter here:

var winner, i = 1;

for each (var row in res) {

    if (i++ === 2) winner = row;

}

View solution in original post