Hello,
I am looking to be able to use a function like the system variable #u in OL workflow in Automate?
Thank you
Denis
Hello,
I am looking to be able to use a function like the system variable #u in OL workflow in Automate?
Thank you
Denis
There are several ways to generate a unique string, depending on the structure you need. One approach I frequently use is the number of milliseconds since the epoch, which can be added to your payload using an inject or change.
Thank you, but I am looking to generate a 16 char for a barcode and the timestamp would not work in that situation.
Alternatively, you can use a Function node and add a module like uuid
. In the Function node, go to the Setup tab, click the Add button at the bottom of the Modules table, and enter uuid
as the module name. This will install the uuid
package from npm. It’s a slightly more involved approach, but it ensures you get a properly formatted UUID and lets you tweak the result, for example, using slice
.
Next, add the following code to the On Message tab:
msg.uuid = uuid.v4().replace(/-/g, '').slice(0, 16);
return msg;
I found this JSONata expression online that might provide exactly what you’re looking for:
$join([0..16].$substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $floor($random() * 27),1))
Add it to a msg property via a change node (make sure to use the J Expression mode):
Thank you this will work for what I looking for.