How to schedule a workflow to prevent executing on Sunday via Schedule Job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 09:53 PM
Hi Everyone,
How to schedule a workflow to prevent executing on Sunday via Schedule Job.
Thanks,
Chhavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:58 PM
@Ravi Chandra_K , Thank you so much 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 11:14 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 11:12 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 01:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 01:31 AM - edited 09-22-2024 01:33 AM
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