Trigger 3 incremental notifications

MStritt
Tera Guru

We would like to set a threshold for registered contacts (customer_contact)who have not logged into their account. If last login time is >365 days for Active accounts, then we will deactivate (Active = false) their account. We'd like to send 3 'warning' notifications in advance of the their account being deactivated. First notification sent 30 days prior to deactivation, the second notification 14 days prior to deactivation, and the final notification one 1 day prior to deactivation.

 

I'm pretty sure using Flow Designer is the best way to do this, but I've no experience creating a workflow. Can I configure everything within the workflow? Or, do I need to create a separate script/job that runs every night to check the last login time on all contact records in addition to the workflow? Any assistance walking through the workflow process would be appreciated.

2 REPLIES 2

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @MStritt ,

 

Create on scheduled job which will run daily.

Create 3 events for 3 reminders and notifications as well. Use below scheduled job to triggered them. Change the event name as per your events.

//Deactivating Users those who doesn't loggedin from last 365 days
var inactive = GlideRecord("sys_user");
inactive.addEncodedQuery("last_login_timeRELATIVELT@dayofweek@ago@365");
inactive.query();
while (inactive.next()) {
    inactive.active = false;
    inactive.update();
}

//Sending Notification 30 days Prior
var Day30 = GlideRecord("sys_user");
Day30.addEncodedQuery("last_login_timeRELATIVELT@dayofweek@ago@335");
Day30.query();
while (Day30.next()) {
gs.eventQueue('eventName',Day30, Day30.user_name, Day30.email);
}


//Sending Notification 14 days Prior

var Day14 = GlideRecord("sys_user");
Day14.addEncodedQuery("last_login_timeRELATIVELT@dayofweek@ago@351");
Day14.query();
while (Day14.next()) {
gs.eventQueue('eventName',Day14, Day14.user_name, Day14.email);
}

//Sending Notification 1 days Prior

var Day1 = GlideRecord("sys_user");
Day1.addEncodedQuery("last_login_timeRELATIVELT@dayofweek@ago@364");
Day1.query();
while (Day1.next()) {
gs.eventQueue('eventName',Day1, Day1.user_name, Day1.email);
}

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Thanks Gunjan!

 

A few questions.

1. Do I need to create 6 Events total? One for each reminder and one for each notification?

Would I just update the 'eventName' with the name of the Event created for the reminder? Or the notification?

//Sending Notification 30 days Prior
var Day30 = GlideRecord("sys_user");
Day30.addEncodedQuery("last_login_timeRELATIVELT@dayofweek@ago@335");
Day30.query();
while (Day30.next()) {
gs.eventQueue('eventName',Day30, Day30.user_name, Day30.email);
}

2. This is specifically for our external registered contacts. Should it be customer_contact instead of sys_user? I don't want this to affect our internal agent users.

3. After thinking about it, I want it to select the locked_out (make true) box instead. So, when the last login time exceeds 365 days, check the locked_out box (true) instead of deselecting (false) the Active box. I want the Active box to remain true, and the locked out box to be true as well. So, the query will be looking for Contacts that have the locked_out box false, where last login time is >365 days. Hope that makes sense.

 

Also, how would I manage the contacts where last login time is already past 365 days? Once this is implemented and it runs the first time, it will automatically lock all those contacts out, correct? And, we wouldn't be able to send any warning notifications.