Invoicing Flow Loop not stopping


I´ve created a flow for managing order invoices. In the flow, all invoices should be process after which the process should moce to “End Process” sequnece. I have an issue with the loop that should execute all the invoices and then move to end process when there are no more invoices. The flow however keeps running on for ever and never swithces over to the end process sequence.

How should I fix the loop to make sure that after processing all invoices (now it´s 2 by default) it moves over to the end process sequence?

invoices (1).xaml (32.9 KB)

@Roggi I would suggest you to have counter (number of invoices). Have a check before it goes to getNextinvoice.If it is less than or equal , it will have to loop through. else, it will come out.

1 Like

@Sugumar8785 thanks for the answer!

In the flow where the loop should start the condition is numberOfInvoices>0, and then in the two last sequnces in the flow I decrease the processIndex variable. I had a counter there that didnt´help.
Should I add the counter before the first true/false flow decision?

1 Like

@Roggi Remove the connection from enterDatatoAccountsPayableSystem to getNextInvoice.

Then connect Process the Invoice with Existing Invoices. (Attached the modified workflow)

It should work.

invoices (1).xaml (32.5 KB)

1 Like

@Sugumar8785 I added a counter using Do While, but it´s not working yet, do I have the values incorrectly? The invoices start at 2 in my example so I want to deduct 1 from the total in the counter. invoices_1.xaml (36.0 KB)

Hi Sugumar,

could you please tell in more detail where exactly I should place the counter? Is it within the first sequence or as a Do while before the first flow decision? I´ve tried a number of options but I´m still unable to get the flow to work correctly. It either loops forever or gives an error.