Script to Generate a UUID
I need to generate a UUID according to UUID V4 and believe this will require a script in order to do this? Whats the best approach for generating this everytime a record is passed in a flow. I also tried the Celigo AI to do this, but didnt have much success (could very well have been I wasnt prompting it correctly).
Thanks!
-
Hi Dave,
I believe, you just need to use the handlebar "random" : https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-helper-reference#random0 -
0
-
You would need something like this. Since it's v4, 4 needs to be hardcoded in the 3rd section.
{{random "uuid" "8"}}-{{random "uuid" "4"}}-4{{random "uuid" "3"}}-{{random "uuid" "4"}}-{{random "uuid" "12"}}
0 -
You guys are the best! Thanks so much Youssef and Tyler!
0 -
I'm not sure why, but Tyler's handlebar formula did not work for me. Even hardcoding the 4 into the 3rd segment, it was still getting rejected. After playing around for a while, I finally came up with this. Basically the same concept, except it takes a valid string from each segment of several full UUIDs instead of explicitly specifying the segment length in the Random function.
{{substring (random "uuid") 0 8}}-{{substring (random "uuid") 8 12}}-{{substring (random "uuid") 12 16}}-{{substring (random "uuid") 16 20}}-{{substring (random "uuid") 20 32}}
0 -
Mike Gonzalez good catch! When I put your output into a UUID validator, it comes out good whereas mine comes out not good.
0 -
Thanks Tyler! I'm just glad the solution did not require a script as I have to send a unique UUID in the request header of all calls including the refresh token request.
Does Celigo Community have an idea portal? I'd like to suggest that they develop a similar Random function to return back a fully formatted UUID with separators as that appears to be a fairly common requirement.
0 -
Hi Mike Gonzalez,
The most efficient and easiest way would be to submit your idea through our Product Portal. You can also see what's coming in the future and provide input on existing ideas.
Thanks!
0
Please sign in to leave a comment.
Comments
8 comments