Filter by users registered in the HR profile by referencing sys_user
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-20-2025 10:48 PM
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.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-21-2025 12:20 AM
@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?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-21-2025 12:39 AM
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.
Cheers,
Tai Vu
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-21-2025 12:40 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-24-2025 11:16 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
02-25-2025 03:21 AM
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader