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

Kevin Bumber
Tera Contributor

I was wondering how many user records in my instance did not have a corresponding HR Profile record created. I couldn't seem to find this elsewhere on the community, so I figured I'd share.

Running a fix script similar to what is written below should print out an info level log message for each User sys_id which does not have a corresponding HR Profile record (yet).

var userGR = new GlideRecord('sys_user');
//userGR.setLimit(100);
userGR.query();

var missingHR = [];
var userIDs = [];

while(userGR.next()){
	var hasProfile = new sn_hr_core.hr_Profile(userGR, gs).userHasProfile(userGR.sys_id);
	if(hasProfile){
		userIDs.push(userGR.getValue('sys_id'));
	} else {
		missingHR.push(userGR.getValue('sys_id'));
	}
}

//gs.info('KMB: userID ' + userIDs[0]);
for(var i = 0; i < missingHR.length; i++){
	gs.info('KMB: missingHR ' + missingHR[i]);
}

find_real_file.png

*this works in the following version

Build name: London
Build date: 12-20-2018_1717
Build tag: glide-london-06-27-2018__patch4-hotfix2-12-20-2018

Comments
Sunny24
ServiceNow Employee
ServiceNow Employee

Is there a script for us to generate the hr profile for those users after this? 

Arlene H
Tera Expert

Hi,

 

You can also create a report of Users with No HR profile instead of running a script and put it on your dashboard.  Here's a screenshot from my report:

 

Source type: Table

Table: User [sys_user]

 

 

arleneh_0-1707082375294.png

 

This will then show all Users with no HR Profile.  Hope this helps.

 

 

 

Version history
Last update:
‎02-07-2019 08:54 AM
Updated by: