Avatar

Level 4

HI Team, 

 

Scenario : in javascript i have an array of deliveries -  for say - "birthday1", "birthday2" and i need to save the statistics of these two deliveries like for : sucessfull sents(based on broadlog table), opt-out(based on tracking table) to a variable of javascript and push them into excel file. 

 

i did like this in javascript : 

 

vars.iteration = getOption("iteration") // initially to 0

 

var array = ["Birthday_Dynata%Mar%2020" , "Birthday_Dynata%Jun%2020"];

 

vars.templateName = array[vars.iteration]; //"Birthday_Dynata_MO_AU_Mar 2020";
vars.fromDate = '03/01/2020';
vars.toDate = '03/31/2020';

 

// through sql i am getting some counts based on template name and dates


vars.success = "select count(*) from NmsBroadLogRcp B1 JOIN NmsDelivery D2 ON (D2.iDeliveryId = B1.iDeliveryId) and "+
"D2.sLabel like '"+ vars.templateName +"' and (B1.tsEvent>='"+ vars.fromDate +"' and B1.tsEvent<='"+ vars.toDate +"')";

vars.succSent = sqlGetInt(vars.success) // success count of Mar emails for 1st iteration 

 

vars.optouts = ".... same as above ...."

vars.optcounts = sqlGetInt(vars.optouts) // opt out counts of Mar emails for 1st iteration 

 

now i want to store these two variables into excel file.. 

for this i did an enrichment activty : 

Ramaswami_0-1591377262838.png

enrichment : (For example, lets take only one variable here say : success )

Ramaswami_1-1591377299510.png

 

Ramaswami_2-1591377361712.png

This is the test condition : 

 

Ramaswami_3-1591377448165.png

 

so the problem is if i don't iterate two time i can export the data like below : 

 

Ramaswami_4-1591377514909.png

 

but when i iterate it twice my 'test' is always failing. Seems like i can't able to get my instance variable 'iteration' to validate in test node : 

i tried : vars.iteration, instance.vars.iteration also but i can't able to pass this test condition - 

Ramaswami_5-1591377593611.png

 

Even if test condition is passed i am not sure if i get the second row in excel sheet