- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-02-2020 12:05 AM
Since I didn't find an OOTB action in the Flow Designer for generating random numbers, I did it by myself.
Attached a PDF that explains how to do it.
Enjoy
William
- 2,006 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This worked really well. I needed to generate a random duration to pass to a Wait for Duration Flow operator. I added on you script, but kept the original as it makes the Action more versatile for other uses:
(function execute(inputs, outputs) {
var min = Math.ceil(inputs.min);
var max = Math.floor(inputs.max);
var result = (Math.random() * (max - min)) + min; //max excluded, min included
var minutes = Math.floor(result).toString();
//duration in minutes
var duration = new GlideDuration('00:'+minutes+':00');
outputs.resultdecimal = result;
outputs.resultint = Math.floor(result);
outputs.resultstring = Math.floor(result).toString();
outputs.resultduration = duration;
})(inputs, outputs);