Im having trubles to stop the loop in a incoming invoice exersice. The automation runs and never stops
I havent used the “do while” activity. I have just connected the process an invoice sequence back to the flow desicion. The flow desicions condition is numberOfInvoices>0 and the value is numberOfInvoices -Int32-2
@Merita26
Make sure you’re actually decreasing numberOfInvoices every time you process an invoice. If you don’t then it will always be 2, so the condition will always be true.
Then as Merita26 said, make sure the value of numberOfInvoices is assigned to numberOfInvoices - 1 at the end of your Process an invoice flowchart. Since this is a flowchart, make sure the value is being decreased regardless of which flow path the flowchart takes. You could even have it do this between the transition from Process an invoice to the condition.
1.) Make sure you’re only decreasing the value of numberOfInvoices one time. If you’re decreasing it 2 or more times, the process will only run once.
2.) Make sure you don’t have numberOfInvoices defined twice (once in the Automated invoice process scope and again in a lower scope. You’ll know this is happening if you see the variable twice in your underlying Process an invoice flowchart where you’re changing the variable. There will be 2 variables, and each will have a warning sign next to them. You only want to keep the global one.
I don’t see where you’re decrementing numberOfInvoices, but you can do this immediately after Start. Then your process will only run twice as long as you’re not reassigning it anywhere else.
If you have only 2 invoices (and you know it will always be 2 invoices), the default should remain as 2. Use an Assign activity in your process flow, and set numberOfInvoices = numberOfInvoices - 1 after the Start of the Process an invoice flowchart. As long as you’re not updating the value anywhere else, the process will run twice before reaching the end state.