How to log into journal and store open ratio of deliveries using javascript | Community
Skip to main content
akashaj7696
Level 3
Mar 9, 2021 1:37 PM UTC
Solved

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

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
_Manoj_Kumar_
_Manoj_Kumar_Accepted solution
New Participant
Mar 13, 2021 2:07 PM UTC

@akashaj7696 

 

Try this:

 

logInfo("The value of open ratio is " +""+vars.ratio+"");
     Manoj     Find me on LinkedIn

7 replies

_Manoj_Kumar_
_Manoj_Kumar_Accepted solution
New Participant
Mar 13, 2021 2:07 PM UTC

@akashaj7696 

 

Try this:

 

logInfo("The value of open ratio is " +""+vars.ratio+"");
Translate
     Manoj     Find me on LinkedIn
akashaj7696
Level 3
Mar 13, 2021 4:22 PM UTC
How to use this? can you explain?
Translate
kapilKochar
Level 6
Mar 10, 2021 4:57 AM UTC

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

Translate
akashaj7696
Level 3
Mar 10, 2021 9:46 AM UTC

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,

Translate