How to generate random numbers based on conditions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:07 AM
How to generate random numbers based on conditions?
Scenario:
The Quality check rules runs on these parameters:
-->If Quality check is true , it will go inside and check below conditions.
- Threshold limit : It will be amount based limit. All requests greater than or same would be eligible for the quality check.
- Random Number : Every time when the request is sent for Quality check, workflow will generate Random number. If the number is greater than the configuration defined, then it will be triggered for QC Group
For example: if Client wants 50% of the Requests to be sent for QC and if the Random number is less than or equal to 0.5 then such Requests will be sent for QC group.
- Sequence Number:Based on the number defined in this field the Requests will be triggered for QC check.
Request number/Sequence number = Integer without decimal then such request will be qualified for QC check.
For example:
- if Sequence Number is 5 and the Request number is SO00004 then 4/5=0.8 this request will skip QC Check.
- if Sequence Number is 5 and the Request number is SO00005 then 5/5=1 this request will be sent for QC Check.
Note: Only one of the above defined parameters will be selected for QC check.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:26 AM
Hello,
I don't understand the fll reach of this, but what i guess is, that the qc must be done on a random basis.
Firstly: If you are doing QC based on the survey functionality by servicenow, you can define these parameters as survey trigger conditions -> https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/survey-administration...
If you truly want to have this within a workflow, design a function that will take these parameters and returns a true/false value. For the random number a function like this would work well:
function getRandomInt(percentage) {
var randomInteger = Math.floor(Math.random() * Math.floor(100));
if(randomInteger/percentage <= 50)
return true;
return false;
}
Regards
Fabian