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-29-2024 08:38 AM
There is the below line which expects a single sys_id value only:
con.addQuery('sys_id', userss);
and you can delete it
you can merge the 2 query conditions as follows:
con.addEncodedQuery('accountISNOTEMPTY^sys_idIN' + userss);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 11:37 AM
Hi @Antoni Zahariev ,
I tried with the Encoded Query nothing working. yeah it seems like it is working for only one value. but in my case have to check both values.
Its frustrating..
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 12:48 PM - edited 10-29-2024 01:12 PM
Hi @Samiksha2
Try this for the variable userss:
var userss = new GlideRecord('sys_user');
userss.get(user_id);
I'll try to reproduce here as well.
EDIT:
Try this way on your script:
var con = new GlideRecord('customer_contact');
con.addEncodedQuery('accountISNOTEMPTY');
con.addQuery('sys_id', userss);
con.query();
if (con.next()) {
if ((con.getDisplayValue('u_bl_contact').toLowerCase().indexOf('ABC') >= 0 ||
con.getDisplayValue('u_bl_contact').toLowerCase().indexOf('XYZ') >= 0 ||
con.getDisplayValue('u_bl_contact').toLowerCase().indexOf('ABX') >= 0 || {
answer = true;
} else {
answer = false;
}
}