- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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'
});
Solved! Go to Solution.
- Labels:
-
Human Resources Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Updating my reply. It works now
Here is the setup that we've come up in the variable under variable set.
Then in script on record producer, we use the dot-walk as @palanikumar had mentioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
3 weeks 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
3 weeks ago - last edited 3 weeks ago
Updating my reply. It works now
Here is the setup that we've come up in the variable under variable set.
Then in script on record producer, we use the dot-walk as you had mentioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @pjftenorio ,
Nice to see that my suggestion helps you. You can also add condition in reference qualifier condition to check if user.active is true to avoid inactive users being listed.
Please mark my response as correct solution if it solves your issue.
Palani
