How to schedule a workflow to prevent executing on Sunday via Schedule Job

Chhavi Dixit
Tera Contributor

Hi Everyone,

 

How to schedule a workflow to prevent executing on Sunday via Schedule Job.

 

Thanks,

Chhavi

9 REPLIES 9

sachinbhasin11
Tera Guru
Tera Guru

Can you provide the details of your workflow? What is the trigger condition, which table?

 

Are you using a workflow or flow?

HI @sachinbhasin11 ,

I have created a new field 'Is Critical' on Incident table, once this field is checked (mark as TRUE) then workflow will start and change the Priority to Critical and Trigger Approval to User 'System Administrator':

ChhaviDixit_0-1726984256947.png

ChhaviDixit_1-1726984493191.png

Please guide me, how I can put condition n Scheduled Job and Run the script accordingly.

Thanks!

Chhavi

 

 

Hi Chhavi,

 

Thanks for sharing, I think Ravi has provided the guidance on how to trigger the workflow on a specific day of the week.

 

However, I feel you can use the same business rule to set your values as well and don't call a separate workflow to do the same. This way all your processing logic remains in one single object 

 

 

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Chhavi Dixit

assuming you have the script ready to call workflow from Scheduled Job, please find below conditional script to exclude Sunday 

// 0=Sunday,

// Get today's date 

var today = new Date();

dayOfWeek = today. getDay(); 

 

if (dayOfWeek > 0 && dayOfWeek < 7){ //it will iterate from Monday to Saturday 

answer = true;

}

else {

answer = false;

}

 

refer:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/washingtondc/new_to_servicenow/app_st...

 

You can also refer

https://www.servicenow.com/community/developer-forum/run-the-scheduled-job-only-on-weekdays-except-s...

Please mark the answer as helpful and correct if helped.

Kind Regards,

Ravi