Hello, I need to generate unique, sequential invoices. I’m after suggestions for the best way of achieving this. I’ll be creating several hundred invoices at once. I was thinking I’d use an asset and increment the integer by one each time, but I am worried about the risk of duplication if there is a lag between the write and read of the asset (especially if I use multiple bots to process).
Then I thought I’d put the question to the group - how would you do this to ensure your invoices have unique and sequential numbering?
Hi @JohnMac,
If there are cases I need something to be always unique, I use the date time in yyyyMMddHHmmss format. Maybe you can consider millisecond if you think there’s still a chance of duplicate by the second. Maybe trim the year to yy if you want a shorter one.
Hey,
you can use guid. It will be for sure unique value
Guid.NewGuid.ToString
Yeah, that was my first thought too. But it has to be sequential, so first is 0001, second is 0002 etc. and so on. That rules out GUID and a time string.
It’s looks like that you need somethng like incrementation of id.
But how to achieve this ? Maybe you will use DB or Excel and you will create and assign number for every new invoice number ?
Yeah this will be tricky. This is somehow in the same boat of a lot of bots accessing 1 file.
Is there a chance that you do your increments within your dispatcher? In that case, your reading/updating asset might work.
I am thinking of a easier way here.
Let’s say in my Robot A i have 2 functionalities.
-
Invoice generation (Let this process create invoices by generating random numbers. Ex:- 12345Invoice.pdf, 22456Invoice.pdf, etc. Both Robots can generate invoices independently.The moment all the invoices are generated , we can update an asset value as ‘TRUE’)
-
Invoice Sequencing( If the asset value is found to be true, the bot will pick all the invoices from shared/local folder based on Descending order of time . It replaces the random number with sequences. So 22456Invoice.pdf–>00001Invoice.pdf , 12345Invoice.pdf–> 00002Invoice.pdf)
Hope this helps.
I think to use assets is risky. It can can be changed by anyone with access to assets.
I prefer DB. It can also store the value with invoice number which will be incrementing and updating and accidentally is harder to change
Oh, this is clever - I like this. So I have separate processes for generating and a single process assigning the correct numbering in batches and sending. I like this!
Waiting to see what else comes through, but this is looking like the best solution so far…
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.