How to Filter Users with HR Profiles

pjftenorio
Giga Guru

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:

pjftenorio_0-1759423652488.png

 

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'
});

 

1 ACCEPTED SOLUTION

Updating my reply. It works now

 

Here is the setup that we've come up in the variable under variable set.

pjftenorio_0-1759489131862.png

 

Then in script on record producer, we use the dot-walk as @palanikumar had mentioned.

pjftenorio_1-1759489196081.png

 

 

View solution in original post

7 REPLIES 7

Abhishek_Thakur
Mega Sage
Mega Sage

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.

Abhishek_Thakur_0-1759430763019.png

 

If my response helps you, please mark this as accepted solution and give thumbs up.

Regards,

Abhishek Thakur

Updating my reply. It works now

 

Here is the setup that we've come up in the variable under variable set.

pjftenorio_0-1759489131862.png

 

Then in script on record producer, we use the dot-walk as @palanikumar had mentioned.

pjftenorio_1-1759489196081.png

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@pjftenorio 

Since you made the variable point to HR Profile table, you should remove any ref qualifier applies

share your variable config screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader