- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 12:37 PM
I have a particular workflow that is getting triggered to close to other instances of itself, and its causing problems where some of the steps are still in process from other instances, so I am trying to space them out in the workflow. I am trying to generate a random number between 0-10, and then will multiply that by 60 to get however many minutes to set the wait timer to. However, I am having trouble with the syntax and am looking for some help.
var workflow.scratchpad.wait = Math.floor(Math.random() * (10 - 0)) + 0;
I am getting an incomprehensible error from this line, and need some help on formatting, or otherwise getting some randomness I can use. Thanks!
jeff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 01:03 AM
try this logic
workflow.scratchpad.wait = Math.floor(Math.random() * 11) * 60;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 01:03 AM
try this logic
workflow.scratchpad.wait = Math.floor(Math.random() * 11) * 60;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader