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 05:52 AM
Confirm whether the field is a reference field
Use sys_id within if.
Before comparing the value, us .toString().
Put a log on name variable to check whether the value is correct by using gs.info(names)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 06:02 AM
Hi @NitheeshkuS ,
logs are not working on the User criteria dont know why. Yes i used sys_id but still not working.
Thanks.
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 02:05 AM
Hi All,
I am still struggling with the script. Please help me here.
Thanks.
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 06:49 AM
What is the value the "userss" variable?
Are there any results returned after executing the con.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 06:56 AM
Hi @Antoni Zahariev ,
userss is storing logged in user sysid.
var userss = user_id;
Are there any results returned after executing the con.query();-Yes, it is giving value when I am adding a single condition like this:
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") {
answer = true;
} else {
answer = false;
}
}
But if I am adding condition for two values it is not working.
Thanks,
Sam