Event called on Loop Not working

Hello,

I’m having issues with using a loop and calling an event. Inside my loop I have a state set to current item’s array and then it calls an event, I think the code is being run too quickly as the event on triggers the workflow on the last item in the array. I did a console log and managed to log each item it was just not triggering the event correctly.

Here is the code that I wrote:

console.log(val);
instance.publishState(“json_current_item”,val);
instance.triggerEvent(“json_iterate_item”,function(){});

Best Regards,
Joshua Riley