Hi community,
How can I generate a number using the floor method (or other) that is 6 digits in length and always random.
Thank you.
Hi community,
How can I generate a number using the floor method (or other) that is 6 digits in length and always random.
Thank you.
Hi @Gethino
output:
If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel
This is a better solution, since it will always be six-characters long, and is more random than the built-in random variable:
{{ substring(replace(uuid + uuid; "/\D+/g"; emptystring); 0; 6) }}
Not only that, it can begin with padded zeros:
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.
Click on each imported module and save it. You may need to remap some variables.
{
"subflows": [
{
"flow": [
{
"id": 140,
"module": "util:ComposeTransformer",
"version": 1,
"parameters": {},
"mapper": {
"value": "{{substring(replace(uuid + uuid; \"/\\D+/g\"; emptystring); 0; 6)}}"
},
"metadata": {
"designer": {
"x": -824,
"y": -3797,
"name": "Generate random 6-digit string",
"messages": [
{
"category": "last",
"severity": "warning",
"message": "A transformer should not be the last module in the route."
}
]
},
"restore": {},
"expect": [
{
"name": "value",
"type": "text",
"label": "Text"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}