User Profile Widget

rachelconstanti
Mega Sage

On the ServiceNow portal page the user profile widget has a 'team' widget.  

This is reporting on active and non-active users.


This is found here:
1. Go to the portal

2. Click Profile located under the user name

3. The "Team Widget" displays 'my manager', 'My Coworkers' and 'My Direct Reports'
4. 'My Coworkers' and 'My Direct Reports' display both active and non-active (termed) users.


What is needed to change this to only report on active users?  We would want to filter on 'locked out' = true.

 

Thank you,

Rachel

 

1 ACCEPTED SOLUTION

Got it, this would be a customisation to 'EP_MyTeamsUtilsSNC' script include.

You would need to add this query to the getTeamMembers and getDirectReports functions

addQuery('locked_out',false) and you want it false, as true would mean they're locked out.
getTeamMembers: function(userGr){
		var teamGR = new GlideRecord("sys_user");
		teamGR.addActiveQuery();
		teamGR.addQuery('locked_out',false);
		teamGR.orderBy("name");
		teamGR.addQuery("manager", userGr.manager.sys_id);
		teamGR.addQuery("sys_id", "!=", userGr.sys_id);
		teamGR.addNotNullQuery("manager");
		teamGR.query();
		return teamGR;
	},
		
	/**
     * Returns direct reportees of the given user
     * @Param {GlideRecord} userGr - GlideRecord of a user
     * returns {Array}{GlideRecord}
     */
	getDirectReports: function(userGr){
		var directReportGR = new GlideRecord("sys_user");
		directReportGR.addActiveQuery();
		directReportGR.addQuery('locked_out',false);
		directReportGR.orderBy("name");
		directReportGR.addQuery("manager", userGr.sys_id);
		directReportGR.query();
		return directReportGR;
	},

 

View solution in original post

6 REPLIES 6

Jonathan Ting
Tera Guru

@rachelconstanti I've had a look in my personal instance and the widget is only showing active users. 

 

Are you able to check to make sure we're looking at the same widget by right clicking on the widget and confirming it's 'Employee Profile My Team'?

If it's the same widget, make sure the script include that looks up the users hasn't been modified - 'EP_MyTeamsUtilsSNC' and that the non-active users definitely have the 'Active' field set to false on the sys_user table.

Hi Jonathan 

It is the same widget - the issue is that we need to show employees that are flagged active is true and locked out is true.  How can I query on locked out is true?

I'm a bit confused on what you're asking as the widget will already display employees who are active and it doesn't filter out on if they're locked out or not. 

 

This is the code for co-workers lookup in EP_MyTeamsUtilsSNC

	getTeamMembers: function(userGr){
		var teamGR = new GlideRecord("sys_user");
		teamGR.addActiveQuery();
		teamGR.orderBy("name");
		teamGR.addQuery("manager", userGr.manager.sys_id);
		teamGR.addQuery("sys_id", "!=", userGr.sys_id);
		teamGR.addNotNullQuery("manager");
		teamGR.query();
		return teamGR;
	},

 

As you can see it only has the active flag on the query. If it's not behaving that way, I would check that script and the one above it 'EP_MyTeamsUtils' to make sure they haven't been customised. 

But to change the filter, you would be changing it there and that would be a customisation, so you really need to weigh up the benefits of making that change and if you want to deal with the ongoing maintenance of checking during upgrades and patches.

When a user account is disabled in Active Directory we have the mid server, etc. configured to mark the user account has locked out.  We do not touch the active flag.  So what is happening is that users that have termed are still displaying.  There would be many things I would need to change if we changed that behavior.  So rather than change all of that, I want to change the script or something so that it looks at the locked out flag and not the active flag.