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

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

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;
	},

 

Thank you

This line of code is what I was missing

 

teamGR.addQuery('locked_out',false);