Is there a way to create a new GUID? Via python I can do something like this:
python -c 'import uuid; print(uuid.uuid4())'
Is there a way to create a new GUID? Via python I can do something like this:
python -c 'import uuid; print(uuid.uuid4())'
Currently there are probably only two ways. Either you copy your above command into an Execute Command Node or you do it in a Function-Node and use code like this:
I tested the execute command but python is missing in the docker image. The JS function I already know but as you can read in the StackOverflow thread it does not generate perfect GUID’s since the random function is JS is not good enough. This is why I’m searching for a better way since we can’t afford to get the same GUID twice
Did you actually find a sulution to create a GUID?
@Michael_Uray , will this flow work for you?
Thanks, the workflow you proposed works fine, the only disadvantage I see is, that it creates an external dependency on the uuidtools.com web service which creates the UUID
I solved it in the meanwhile by the following way.
I am aware, that Math.random()
does not create the very best randomized numbers, but it is unlikly to receive the same GUID twice.
n8n uses internally the npm module uuid. Meaning you can also use it in the Code-Node. The only thing you have to do is to give it access to it by setting the environment variable NODE_FUNCTION_ALLOW_EXTERNAL
accordingly. Here an example.
I am going to close this thread as it is a bit old now but before I do I also want to leave this…
We have support in the Crypo node to create a UUID so there may not be any need to use a code node or an external web service.
The workflow below contains 4 different ways taken from this thread to generate a uuid.