How to Filter Users with HR Profiles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi, I've already created an Advance Reference Qualifier in Variable Set for Opened For/ Subject Person referenced to table [sys_user] and to filter only users with HR Profiles but since this is a query, loading of users in drop down takes 3-5 seconds before showing and it is a bad user experience.
Is there any way to optimize it?
Variable setup:
Script Include:
var NMHRProfileUtils = Class.create();
NMHRProfileUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
initialize: function() {},
getListUsersWithHRProfile: function() {
var ids = [];
var gr = new GlideRecord('sn_hr_core_profile');
gr.addNotNullQuery('user');
gr.query();
while (gr.next()) {
ids.push(gr.getValue('user'));
}
if (ids.length === 0) {
return 'sys_id=NULL';
}
return 'sys_idIN' + ids.join(',');
},
type: 'NMHRProfileUtils'
});
- Labels:
-
Human Resources Service Delivery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
46m ago
Hi,
The script you have created will return all the user having HR Profile which causes the performance issue.
Can you create reference for HR Profile record instead? From your flow you can get the User record using dot walking.
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
21m ago
Hi @pjftenorio
Yes — that suggestion is absolutely correct and will greatly improve performance.
You're currently referencing the sys_user table and filtering it by querying sn_hr_core_profile, which is expensive.
Instead, reversing the logic — referencing HR Profile (sn_hr_core_profile) directly, and then dot-walking to the user — is both simpler and much faster.
Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
28m ago
Hello @pjftenorio ,
I agree with @palanikumar , currently I am working as a solution architect on HRSD module, and I would recommend making the reference field directly to the HR Profile (sn_hr_core_profile) and apply the simple reference qualifier filter, attaching the below screenshot for your reference.
If my response helps you, please mark this as accepted solution and give thumbs up.
Regards,
Abhishek Thakur