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

Chhavi Dixit
Tera Contributor

@Ravi Chandra_K , Thank you so much 🙂

I have given a script to call the workflow from BR. (The same can be used in BR too depending upon on requirement)

Let me know if it works.

 

Kind Regards,

Ravi Chandra 

Ravi Chandra_K
Kilo Patron
Kilo Patron

Create a Business Rule,

With the same conditions

 Then in Script, use below method to check the dates and call a workflow 

// 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 

var wflw = new Workflow();

wflw.startFlow(wflw.getWorkflowFromName('workflow name'), current, 'update');

 

 

Please mark the answer as helpful and correct if helped 

Ravi 

HI @Ravi Chandra_K ,

 

I am trying to do this via BR, but its not working. 😞

ChhaviDixit_0-1726993078407.png

 

Thanks 

Chhavi

 

Can you use GlideDateTime() instead of Date.

var gdt = new GlideDateTime();

var dayOfWeek = gdt.getDayOfWeek();

//This returns day of the week as integer.

 

add logs to know what values it is returning. (Coincidence, Today is Sunday 😀)

 

 

Please Mark this answer as helpful and correct if helped.

Kind Regards,

Ravi