Filter by users registered in the HR profile by referencing sys_user

NaoyaT
Tera Expert

I created a script to reference sys_user in a catalog item using a variable of type "reference" to filter by users registered in HR profile, but it doesn't work.

 

■Variable
Reference:User[sys_user]
Use reference qualifier:Advanced

Reference qualifier

javascript:
var query;
var grmem = new GlideRecord('sn_hr_core_profile');
grmem.query();

var usrIDs = [];

while (grmem.next()) {
usrIDs.push(grmem.employee_number.toString());
}
query = 'user_nameIN' + usrIDs.join(',');
query;

When a request item is created, we want to use catalog client scripts and script includes to link and display the user with the user ID, so we reference sys_user instead of sn_hr_core_profile.

9件の返信9

NaoyaT
Tera Expert

@Ankur Bawiskar , @Tai Vu , @Debasis Pati 

Thank you everyone for your replies.
I tried what you suggested, but it didn't work.

I created the application with the "Global" scope instead of "human resources: core", so I wonder if this is affecting it?

Is it impossible to achieve with the "Global" application scope?

Hi @NaoyaT 

Let's copy your script and try to execute it in the background script to see if the error below appears.

Security restricted: Read operation on table 'sn_hr_core_profile' from scope 'Global' was denied. The application 'Global' must declare a cross scope access privilege. Please contact the application admin to update their access requests.

 

If yes we need to define a record like below in the sys_restricted_caller_access table.

TaiVu_0-1740127138897.png

 

Cheers,

Tai Vu

 

@NaoyaT 

any reason you created the catalog item and variable in global scope?

You should create it in HR core scope

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

@NaoyaT 

Thank you for marking my response as helpful.

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

@NaoyaT 

Did my reply answer your question?

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