Flow designer duration question

samadam
Kilo Sage

I am developing a  flow where on creation of a case I create a task, after that I want to create a notification if the end date is in 60 days, and then if the end date is 30 days from now create another task. I am trying to do this using Wait for Condition and setting relative dates but will the flow continue to check without any updates to the record? Is there an alternate way to do this? 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

Wait for condition won't help as it will wait till the time the record gets updated and if condition is met then only it proceeds.

Approach

1) create daily scheduled job and search for 60 days and 30 days

2) if difference is 60 days between now date and end date -> send email

3) if difference is 30 days then create another task

something like this

// 60 Days Before End Date
var gr60 = new GlideRecord('your_table_name');
gr60.addQuery('end_date', '>=', gs.daysAgoStart(-60));
gr60.addQuery('end_date', '<=', gs.daysAgoEnd(-60));
gr60.query();
while (gr60.next()) {
    gs.eventQueue('your.custom.notification.60days', gr60, gr60.opened_by.sys_id, '');
    // To create a task, you could instantiate a new GlideRecord for your Task table here
}

// 30 Days Before End Date
var gr30 = new GlideRecord('your_table_name');
gr30.addQuery('end_date', '>=', gs.daysAgoStart(-30));
gr30.addQuery('end_date', '<=', gs.daysAgoEnd(-30));
gr30.query();
while (gr30.next()) {
    // Create another task or fire another event
    // You could also create a task directly here
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

kaushal_snow
Mega Sage

Hi @samadam ,

 

You can create a Scheduled Trigger flow which will run every 12 or 24 hours or as per your choice. Add a Lookup Records action to find cases/tasks with End Date relative to 60 or 30 days.

 

Try this once and let me know. If you find this helpful, please accept this as a solution and hit the helpful button..

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

Wait for condition won't help as it will wait till the time the record gets updated and if condition is met then only it proceeds.

Approach

1) create daily scheduled job and search for 60 days and 30 days

2) if difference is 60 days between now date and end date -> send email

3) if difference is 30 days then create another task

something like this

// 60 Days Before End Date
var gr60 = new GlideRecord('your_table_name');
gr60.addQuery('end_date', '>=', gs.daysAgoStart(-60));
gr60.addQuery('end_date', '<=', gs.daysAgoEnd(-60));
gr60.query();
while (gr60.next()) {
    gs.eventQueue('your.custom.notification.60days', gr60, gr60.opened_by.sys_id, '');
    // To create a task, you could instantiate a new GlideRecord for your Task table here
}

// 30 Days Before End Date
var gr30 = new GlideRecord('your_table_name');
gr30.addQuery('end_date', '>=', gs.daysAgoStart(-30));
gr30.addQuery('end_date', '<=', gs.daysAgoEnd(-30));
gr30.query();
while (gr30.next()) {
    // Create another task or fire another event
    // You could also create a task directly here
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader