Hello Lukman,
The issue you’re experiencing with duplicate invoice numbers is likely due to concurrency problems when running the API workflows on a list, leading to multiple processes generating the invoice number simultaneously. This can result in the system assigning the same number to different invoices.
A more reliable solution would be to implement a recursive workflow with an index-based approach. Here’s how you can do it:
- Create a recursive API workflow: Start by scheduling an API workflow that processes one invoice at a time instead of attempting to process them all simultaneously. Pass in the required parameters for generating each invoice, along with an
index parameter starting at 1.
- Select items by index: Use the
index parameter to select the relevant vendor and items from the list, e.g., item # index. This ensures that only one invoice is created for the current index.
- Increment the index: After each invoice is generated, increment the
index and call the API workflow again, but only if index < list:count. This approach ensures that your workflow processes invoices sequentially and avoids concurrency conflicts.
This method will help prevent duplicate numbers, as each invoice will be generated one at a time in a controlled manner, without overlapping. It should be much more efficient and reliable than using a time interval, providing you with the correct sequence of invoice numbers.
I hope this solution resolves your issue!