cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate unique guids in snaplogic

yash_verma
New Contributor

Hi
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.

Thanks

Yash

6 REPLIES 6

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?

(Date.now().getTime() + 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.