Glide Record check user satisfies the user criteria

Tadz
Tera Guru
Tera Guru

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

6 REPLIES 6

Mohit Kaushik
Mega Sage
Mega Sage

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

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Tadz
Tera Guru
Tera Guru

Hi Everyone, I just did a GlideRecordSecure and it worked.