Generating Unique Transaction ID/Reference Number

uiautomation
activities
studio

#1

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


#2

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 https://stackoverflow.com/questions/39771/is-a-guid-unique-100-of-the-time) :slight_smile:

Thanks,
Josh


#3

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: