User criteria is not working for Knowledge bases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 02:05 AM
Hi all,
I have a requirement to show knowledge bases based on the Business Line.
Business line(List collector - referencing to Business Line table) is in Contact table(customer_contact).
I have created a User criteria and added in the Can read tab of Knowledge base.
My script is
var userss = user_id;
var con = new GlideRecord('customer_contact');
con.addEncodedQuery('accountISNOTEMPTY');
con.addQuery('sys_id', userss);
con.query();
if (con.next()) {
var names = con.u_bl_contact.getDisplayValue();
if ((names == "ABC, XYZ") || (names == "XYZ, ABX")) {
answer = true;
} else {
answer = false;
}
}
In the background script I am getting the true /false values.
But when I added it in the User criteria it is not working.
Please let me know what I am doing wrong.
- Labels:
-
Knowledge Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 04:46 AM
Hi @Samiksha2
Hope you replaced the first line as below
var userss = gs.getUserID();
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 04:51 AM
That would be the incorrect way to design a user criteria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 05:06 AM
Hi @palanikumar ,
In user criteria gs.getUserID() doesnt work.
Thanks,
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 04:53 AM
Are you running the background script in global, and is the user criteria created in global? Using .getDisplayValue is restricted in scoped applications. I'd also recommend against basing the criteria on the display value of a record that can change but instead on the sys_id(s).