Generating Unique Transaction ID/Reference Number

Hi, for a transactional process that I am using I need to be able to create a robust and incrementing transaction ID. By robust I mean that it needs to continue increasing across different instances of the robot. I have thought about possibly saving the current number that it is on in a text file each time the workflow ends and reading that in and assigning it to the variable that continues increasing at the beginning of a new session, but maybe there is a better way? I also considered making a unique hash out of the current datetime or something but I’d like to avoid any overlapping IDs if possible.

Thanks!
-Tyler

Hi there @tjsauter,
You could utilise a GUID, for example:
Guid.NewGuid().ToString

While each generated GUID is not guaranteed to be unique, the total number of unique keys (2^128 or 3.4×10^38) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×10^22 stars; every star could then have 6.8×10^15 universally unique GUIDs.

From Wikipedia
(Stolen from language agnostic - Is a GUID unique 100% of the time? - Stack Overflow) :slight_smile:

Thanks,
Josh

2 Likes

That’s a fantastic answer and I absolutely wish that I could use it in this case, will certainly keep it in mind in the future, but unfortunately I need numbers only (6 digits to play with) and it needs to be predictably incrementing so I can isolate failures by session and we can identify what was done per user.

Thanks though! :grinning:

My apologies for reviving an ancient topic, but I’m currently facing the same problem. Wondering if anyone has any slick solutions :slight_smile:

Right now I’m storing the ID’s in an Excel and incrementing and writing back to it, but I was wondering if there’s a safer / better way.

1 Like

You can store the Id in the Orchestrator Asset. Next time read it from asset and increment it. It will be more slick and asset available across all robots in the tenant.