Wait for condition in scheduled job script.

Ajay37
Tera Contributor

Hi,

I am using a schedule job, where I am querying the records from a table and doing some action for the retrieved records. Now I want to have delay between each record to get that action done (one after the other after few seconds). Could anybody has an idea?

Thanks

1 ACCEPTED SOLUTION

Hi Ajay,

Yes, you can use that way. You would need to use it after you write gr.update() statement so that system will keep delay after every update as per your requirement.

Note: Consider delay timing before executing script e.g. If you are updating  1lakh records then keeping 1 seconds delay for each record will take more than 24hours.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

View solution in original post

12 REPLIES 12

OlaN
Giga Sage
Giga Sage

Hi,

Create a scheduled Flow instead of using a scheduled job. There is a built in action in Flow designer that allows for waits for a period of time.

find_real_file.png

Ajay37
Tera Contributor

Hi,

Thanks @OlaN . The idea you proposed makes scheduled job to run for every interval right? But I want schedule job to run only once a day. And it should set some delay for every record it is doing action on.

Yes, and thats exactly what I had in mind, just didn't show all the steps.

Adding a more complete example below

find_real_file.png

Ajay37
Tera Contributor

Hi @OlaN ,

The thing here is we are using some API related script in scheduled job. So we decided to stay with scheduled job script itself. Could you propose anything related to scheduled job?

Thanks