Notification

KritiK
Tera Contributor

Hi @everyone ,

Use Case- 

There is two due date notification which we are sending, one is sending before 7 days due date and other is before 30 days due date.

As of now written scheduled job, created two event and two notification. it's working but I want to Triger both notification in one notification if anyone have alternative way for this please let me know quickly.

6 REPLIES 6

Rajesh Mushke
Mega Sage
Mega Sage

Hi @KritiK,

 

You can use the two different events with two notifications, are you facing any issue with it ?

if you want keep only one email then make the duration time as dynamic on the email subject or email body wherever is required using the email email script. this way you can trigger only one event with single email.

 

let me know if you need more help!



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

You can use the two different events with two notifications, are you facing any issue with it ?

it's working

VinayNimbalkar
Tera Contributor

Hi @KritiK ,

 

Could you please try this using flow designer? this scenario would be more easier to achieve there. additionally you could have one notification which trigger for both the condition.

 

 

Runjay Patel
Giga Sage

Hi @KritiK ,

 

You can trigger same event from schedule job like below.

var grTask = new GlideRecord('task');
grTask.addQuery('due_date', 'ON', gs.daysAgoStart(-7)); // Tasks due in 7 days
grTask.addOrCondition('due_date', 'ON', gs.daysAgoStart(-30)); // Tasks due in 30 days
grTask.query();
while (grTask.next()) {
    gs.eventQueue('task.due_reminder', grTask, grTask.sys_id, grTask.due_date);
}

 

In Email script use code like below.

var daysUntilDue = gs.dateDiff(gs.nowDateTime(), current.due_date.getGlideObject(), true);

// Generate the appropriate message based on the due date
if (daysUntilDue <= 7) {
    "This is a reminder that the due date is in 7 days.";
} else if (daysUntilDue <= 30) {
    "This is a reminder that the due date is in 30 days.";
} else {
    "No action required.";
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------