Article - Employee Offboarding Report

nayanmule
Kilo Sage

Hello Community,

 

Recently, I had a chance to implement something that I feel is quite helpful for managers in tracking pending items when a user leaves an organization.

 

Whenever a user is offboarded from an organization or in ServiceNow terminologies when a user is marked inactive in servicenow , there's often a gap between the direct manager of the user to understand the pending action items user had before he/she was terminated.

 

Many times , these tasks /approvals/ group memberships remain unnoticed which may cause complaince issues.

To address this, I implemented a notification that is triggered when a user is offboarded.

 

This notification contains a summary of all the pending tasks/approvals for the user. Hence, manager can take an account of those tasks and reassign it to the other team members.

I believe this approach improves accountability and ensures that no critical tasks are left unattended during offboarding.

Notification Example -

nayanmule_0-1766484163981.png

Configurations done to achieve this -

1. Business Rule (to trigger the event and to check if the user gets active false)

After update

Condition - Active changes to False

Table - Sys_user

Script -

 

(function executeRule(current, previous /*null when async*/ ) {

	var parm1 = current.sys_id;
    if (previous.active && !current.active && current.manager) {
        var taskGR = new GlideRecord('task');
        taskGR.addQuery('assigned_to', current.sys_id);
        taskGR.addActiveQuery();
        taskGR.query();

        if (taskGR.next()) {
            gs.eventQueue("user.inactive.pending.tasks", current, parm1, current.manager);
        }

		var approvalGr = new GlideRecord('sysapproval_approver');
		approvalGr.addQuery('approver', current.sys_id);
		approvalGr.addEncodedQuery('state=requested');
		approvalGr.query();

		if(approvalGr.next()){
			gs.eventQueue("user.inactive.pending.approvals",current,parm1,current.manager);
		}
    }

})(current, previous);

 

 

2. Email Script (to form the table , add the link )

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here

    var user = current.assigned_to;

    var taskGR = new GlideRecord('task');
    taskGR.addQuery('assigned_to', event.parm1);
    taskGR.addQuery('active', true);
    taskGR.query();

    if (!taskGR.hasNext()) {
        template.print("No active tasks assigned to this inactive user.");
        return;
    }
    template.print("<table border='1' cellpadding='5' cellspacing='0'>");
    template.print("<tr><th>Task Number</th><th>Short Description</th><th>Link</th></tr>");

    while (taskGR.next()) {
        var taskNumber = taskGR.getDisplayValue('number');
        var shortDesc = taskGR.getDisplayValue('short_description');
        var link = gs.getProperty('glide.servlet.uri') + taskGR.getLink(true);

        template.print("<tr>");
        template.print("<td>" + taskNumber + "</td>");
        template.print("<td>" + shortDesc + "</td>");
        template.print("<td><a href='" + link + "'>View</a></td>");
        template.print("</tr>");
    }

    template.print("</table>");
})(current, template, email, email_action, event);

 

3. Finally the notification to trigger the event , and add the body content that you want.

Table - sys_user

Send - Event is triggered

Subject -  Subject of your email

Message - Summary of your email.

 

 

Found this useful? Don’t forget to mark it helpful and share it with your colleagues.

 

Regards,

Nayan

2 REPLIES 2

Mark Manders
Mega Patron

Shouldn't this be a report that is evaluated between employee and manager before the employee leaves, so any reassigning can be done, including latest status update? If you create a 'Team tab' on a dashboard that so a manager has an overview on every team member, reassigning will also be easier (Jack has 2 incidents assigned to him, Jill has 20, so when Peter leaves, the 4 incidents Peter can't resolve in time go to Jack and because Peter is still there, Jack can ask for a handover.

Emailing when the user account is inactivated means Peter is already gong.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders  , you are right. Thankyou for sharing your inputs on this.

In order to send this before employee terminates, we need to set some trigger rule , some check to find out based on the Last working date of the employee.

This would be another configuration to add a field like LWD on the user profile and then trigger a schedule a week before based on LWD.

 

Also, I like the idea of Dashboards where manager can track the team's work.

 

Regards,

Nayan