Glide Record check user satisfies the user criteria

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 11:48 PM
Hi Everyone,
Is it possible to add user criteria as a query in a GlideRecord?
Lets say, i want to display a knowledge base articles on the portal.
And some articles have user criteria.
I want my gliderecord to return only items that the user has access to.
Thanks,
Tadz
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2020 12:31 AM
Hi There,
You can access the KBs by filtering the user criteria as per the logged in user by using the below script
var uc = new GlideRecord('user_criteria');
uc.addQuery('user',gs.getUserID()); //to find the UC based on logged in user
uc.query()
while(uc.next())
{
var ucToKb = new GlideRecord('kb_uc_can_read_mtom'); //for 'can read' UC it will find KB
ucToKb.addQuery('user_criteria',uc.sys_id);
ucToKb.query()
while(ucToKb.next())
{
gs.print(ucToKb.kb_knowledge_base) //sys_id of kbs
}
}
Once you have the list if KBs accessible to users then you can surely glide the Articles for those KBs
Please mark this answer as correct and helpful as per the impact. And only helpful if it lead you in right direction.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2020 01:59 AM
Hi Everyone, I just did a GlideRecordSecure and it worked.