Hi! I am trying to retrieve facts in a for loop, coz Im sending differenct array objects to the rules, but when I retrieve, only the first object sent to the engine is retrieve. I dont know why. Here is my code:
for(var i = 0; i < rows.length; i++){
ev[i] = new Event(rows[i].id, rows[i].name, rows[i].code, rows[i].category_id, rows[i].inventory, rows[i].type,
rows[i].value, rows[i].total);
eventSentToRule = flow.getSession(ev[i]); //assert event
//Fire rules and retrieve facts
eventSentToRule.on("event", function (obj) { eve = obj.event;})
.match().then(function (err) {
if(err){
console.error(err);
res.redirect('/home');
}else{
if(eve){
eventOutputFromNools[i] = eve;
console.log("Type: " + eventOutputFromNools[i].type);
//console.log(eve.type);
eventSentToRule.dispose();
res.redirect('/newsponsorship');
}
}
});
eventSentToRule.dispose();//this remains
}
Where eventOutputFromNools is declared ?
Are you sure you can't accomplish this in another way ?
Keep in mind that you should not have too much logic out of your rules..
Hi! I am trying to retrieve facts in a for loop, coz Im sending differenct array objects to the rules, but when I retrieve, only the first object sent to the engine is retrieve. I dont know why. Here is my code:
And my nools rule engine is as follows:
So it seems like I can only get
eventOutputFromNools[0]
Thanks for the help