- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 11:37 AM
I know the 'Generate HR Profiles' module exists, but I need a way to also generate profiles for users who are inactive, not just active.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 12:06 PM
Since the creation of HR profile is a core feature of SN, it is not possible to create an HR profile if user is inactive.
However, there is OOB BR "Create HR Profile for users" which allows to create a HR profile through script. We can use that code and can create HR profile for inactive users as well. This is present in HR Scoped application.
So go to that application and write a simple fix script like below and run it. It will create HR profiles for all inactive users.
var gr = new GlideRecord("sys_user");
gr.addQuery("active","false");
gr.query();
while(gr.next()) {
var user = gr.getValue("sys_id");
var gr1 = new GlideRecord('sn_hr_core_profile');
gr1.addQuery('user',user);
gr1.query();
if(!gr1.next()){
var hrProfile = new hr_Profile();
hrProfile.createProfileFromUser(user);
}
}
Mark the comment as a correct answer and also helpful once worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 12:06 PM
Since the creation of HR profile is a core feature of SN, it is not possible to create an HR profile if user is inactive.
However, there is OOB BR "Create HR Profile for users" which allows to create a HR profile through script. We can use that code and can create HR profile for inactive users as well. This is present in HR Scoped application.
So go to that application and write a simple fix script like below and run it. It will create HR profiles for all inactive users.
var gr = new GlideRecord("sys_user");
gr.addQuery("active","false");
gr.query();
while(gr.next()) {
var user = gr.getValue("sys_id");
var gr1 = new GlideRecord('sn_hr_core_profile');
gr1.addQuery('user',user);
gr1.query();
if(!gr1.next()){
var hrProfile = new hr_Profile();
hrProfile.createProfileFromUser(user);
}
}
Mark the comment as a correct answer and also helpful once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 07:48 AM
Hey asifnoor,
Thanks for the advice on using the hr_Profile script include. I wrote a fix script, modifying your suggested code as we have quite a large User table. The below code is what I have implemented and it's successfully generated HR Profiles for inactive User records that didn't have HR Profiles.
var grU = new GlideRecord("sys_user");
gr.addQuery("active","false");
grU.query();
var hrProfile = new hr_Profile();
while(grU.next()) {
if(!hrProfile.userHasProfile(gr.sys_id)){
hrProfile.createProfileFromUser(user);
}
}