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

How to log into journal and store open ratio of deliveries using javascript

akashaj7696
Level 3
Level 3

Hi Everyone,

 

I'm facing an issue in displaying and storing the value of open ratio using JavaScript. I have used the below code, please let me know where i'm wrong.

 

// 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="@internalName"/>;
<node expr="[@operation-id]" alias="operationId2"/>
<node expr="[indicators/@estimatedRecipientOpenRatio]" alias="ratio"/>
<node expr="[indicators/@totalRecipientOpen]" alias="estimated"/>;
</select>
<where>
<condition expr="@internalName='DM187125'"/>
</where>
</queryDef>).ExecuteQuery();

for each (var w in winner){
vars.ratio = w.@ratio;
logInfo("The value of open ratio is " +vars.ratio); - This displays blank.
logInfo(winner); - This displays all the values in the journal.
}

Any help would be appreciated.

 

Thanks,

Akash

1 Accepted Solution
Manoj_Kumar_
Correct answer by
Community Advisor
Community Advisor

@akashaj7696 

 

Try this:

 

logInfo("The value of open ratio is " +""+vars.ratio+""); 

View solution in original post

7 Replies
kapilKochar
Community Advisor
Community Advisor

Hi Akash,

 

Try this this should work inside for loop and rest of your code is fine

 

for each (var w in winner.ratio)

{
logInfo("The value of open ratio is " + w);
}

 

Thanks,

Kapil Kochar

akashaj7696
Level 3
Level 3

Hi Kapil,

Appeciate your help.

I used the below code but i still get blank.

 

// 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="@internalName"/>;
<node expr="[@operation-id]" alias="operationId2"/>
<node expr="[indicators/@estimatedRecipientOpenRatio]" alias="ratio"/>
<node expr="[indicators/@totalRecipientOpen]" alias="estimated"/>;
</select>
<where>
<condition expr="@internalName='DM187125'"/>
</where>
</queryDef>).ExecuteQuery();

for each (var w in winner.ratio)
{
logInfo("the winner is" +w);
}

 

Thanks,

kapilKochar
Community Advisor
Community Advisor
working fine for me.. i tested it on my instance.. also you can try to check value for operationid2 by using below for each (var w in winner.operationId2)
kapilKochar
Community Advisor
Community Advisor

working fine for me.. i tested it on my instance.. also you can try to check value for operationid2 by using below for each (var w in winner.operationId2){logInfo("Operation Id is "+w)}

Manoj_Kumar_
Correct answer by
Community Advisor
Community Advisor

@akashaj7696 

 

Try this:

 

logInfo("The value of open ratio is " +""+vars.ratio+""); 

View solution in original post