- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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..
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader