WorkFlow Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2024 10:35 PM - edited ‎09-26-2024 06:10 AM
Hi
my requirement is in catalog item if catalog task is in open(not closed) then it should trigger email after 1 day if task is still in open state ,like wise after 3 days,7 days,15 days if it is closed at after 3 days remaining notifications should not trigger this should be done using workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2024 11:16 PM
Hello @dixitreddy,
Please see the below screenshot and let me know whether it is helpful or not.
Thanks
SP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 03:19 AM
if catalog task closes after timer1 then remaining notifications will trigger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 03:54 AM
hi @dixitreddy
you can achieve this functionality by scheduled job & flow designer (recommended)
Here i am providing the scheduled job script (frequency - daily; time - set as per your requirement)
// Define the notification intervals
var intervals = [1, 3, 7, 15]; // Days after which to send notifications
// Get the current date
var currentDate = new GlideDateTime();
// Loop through each interval
for (var i = 0; i < intervals.length; i++) {
var days = intervals[i];
// Calculate the date threshold
var thresholdDate = new GlideDateTime(currentDate);
thresholdDate.addDays(-days); // Subtract the number of days
// Query catalog tasks that are still open and were created before the threshold date
var taskGR = new GlideRecord('sc_task');
taskGR.addQuery('state', '!=', 'Closed'); // Ensure the task is not closed
taskGR.addQuery('sys_created_on', '<=', thresholdDate);
taskGR.query();
while (taskGR.next()) {
// Check if an email has already been sent
if (!hasNotificationBeenSent(taskGR.sys_id, days)) {
// Send notification
sendNotification(taskGR);
}
}
}
// Function to check if a notification has already been sent
function hasNotificationBeenSent(taskId, days) {
var notificationGR = new GlideRecord('sys_email');
notificationGR.addQuery('table_name', 'sc_task');
notificationGR.addQuery('table_sys_id', taskId);
notificationGR.addQuery('subject', 'CONTAINS', 'Reminder: Task still open after ' + days + ' days');
notificationGR.query();
return notificationGR.hasNext();
}
// Function to send the notification
function sendNotification(taskGR) {
var email = new GlideEmailOutbound();
email.setTo(taskGR.requested_for.email); // Change as necessary for your recipient
email.setSubject('Reminder: Task still open after ' + days + ' days');
email.setBody('This is a reminder that your catalog task ' + taskGR.number + ' is still open.');
email.send();
}
I hope this will helps you
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 05:26 AM
Thank for ur answer but i need to add this functionality to existing workflow