Instead of gs.sleep(delayInSeconds * 1000); what is the exact function i have to use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:13 AM
Hi Team,
Can you please suggest what are the exact function we have to use instead of
I have tried with this script also, but no use.
My requirement is send mails one by one, but each sending mail give 1 minute delay. I have tried the script is. It is working as expected but impacting the system performance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:39 AM
it will work in both.
Sleep will impact performance.
what's your business requirement here?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 07:04 AM
Hi @Ankur Bawiskar,
My business requirement is sent mails to all delegate users.
Send one by one but give delay of 10 minutes of each sending mail.
when using gs.sleep it is working as expected but it impacting the total system performance.
So please suggest what i have to use Instead of 'gs.sleep'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 07:34 AM
Hi @Kusuma Sai ,
you can use schedule job, it will not lead to system performance.
var job = new GlideRecord('sys_trigger');
job.initialize();
job.name = "Delayed Task";
job.script = 'action to take after delay';
job.next_action = new GlideDateTime().addSeconds(300); // Schedule 5 minutes from now (or adjust)
job.insert();
Accept the solution if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 08:07 AM
@Runjay Patel , I have tried this solution before, after running the schedule job it was executed directly and sent all mails at a time.
There is no delay between sending each mail