How to generate unique guids in snaplogic

I am using math.random() function of mapper component to generate unique guids. I am worried that after repetitive use of this function it will generate duplicate results. Is there any way i can be sure that it doesnt generate same guids. Is there any other efficient way of doing this. Please let me know.



Use Math.randomUUID() instead.

sorry I am using math. Randomuuid () only. So this function you are saying will never return same guids.? Pls let me know as if it return duplicates than my solution will be ruined.

I see. Well, a random UUID is a 128-bit random value, so repeated values are VERY unlikely. But if you wanted to guarantee uniqueness, you could concatenate a timestamp:

Math.randomUUID() +

Yes i can do that but it wont be a 128 bit guid if i add date. Anyother option u would like to propose.

No. I’d just use a randomUUID. You’re extremely unlikely to get repeats. We use them all the time when we need unique values and I’m not aware of any issues related to repeats.

Actually, how about this?

( + Math.randomUUID()).substr(0,36)

That will give you a value like 16008933027615cf16319-1480-4260-9c84. The time component changes every millisecond, plus a random component, and it’s the length you want.