The CreatorCon Call for Content is officially open! Get started here.

Notification to group manager's manager when group manager is about to leave the organization

pawan2
Tera Expert

Hi All,

 

Greetings!

 

We are planning to trigger a notification to current group manager's manager when current group manager leaves in 15 days and 7 days. We have the Last working date field in the sys_user table that we can utilized.

 

I would like to know your thought to understand how we can trigger a notification for each group manager's manager. Possibly as part of a scheduled job or a flow. Appreciate your thought and let me know if you already have such a function.

 

Thanks,

Pj

4 REPLIES 4

Sumanth16
Kilo Patron

Hi @pawan2 ,

 

Create business rule on sys_user table and select active changes to false condition

 

 

var gr = new GlideRecord('sys_user_group');
gr.addEncodedQuery('active=true^manager.active=false');
gr.query();
if(gr.next()){    
if()gr.manager==true){
gs.eventQueue("manager.left",gr,gr.manager.manager, gr.manager);//replace with you field names
}
}

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Maddysunil
Kilo Sage

@pawan2 

You can write schedule job and can trigger the notification based on requirement, below is the sample code you can you it:

 

// Query for group managers whose last working date is within 15 days and 7 days
var groupManagerGr = new GlideRecord('sys_user');
groupManagerGr.addQuery('active', true); // Only active users
groupManagerGr.addQuery('manager', '!=', ''); // Users who have a manager
groupManagerGr.addQuery('user_type', '!=', 'service_account'); // Exclude service accounts
groupManagerGr.addQuery('sys_user_group', 'ISNOTEMPTY'); // Users belonging to a group
groupManagerGr.addQuery('sys_user_role', '=', 'admin'); // Assuming 'admin' role signifies group manager, adjust as needed
groupManagerGr.addQuery('last_working_date', '>=', gs.daysAgoStart(15)); // Last working date within 15 days
groupManagerGr.addQuery('last_working_date', '<=', gs.daysAgoStart(7)); // Last working date within 7 days
groupManagerGr.query();

while (groupManagerGr.next()) {
    var manager = groupManagerGr.manager;
    // Retrieve manager's details
    var managerGr = new GlideRecord('sys_user');
    if (managerGr.get('sys_id', manager)) {
        // Trigger notification to manager's manager using gs.eventQueue()
        gs.eventQueue('notification.event', managerGr, groupManagerGr.name); // Pass necessary parameters

        gs.info('Notification event queued for group manager: ' + groupManagerGr.name + ', Manager: ' + managerGr.name);
    }
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Harish KM
Kilo Patron
Kilo Patron

Hi @pawan2 you can use flow designer and look up table and send Notification, no code is requried just use correct data pills.

Regards
Harish

pawan2
Tera Expert

Hi All,

 

Thank you so much for all your responses. Let me try one by one. Much appreciated your support!

 

Thanks,

PJ