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.