User criteria is not working for Knowledge bases

Samiksha2
Mega Sage

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.

22 REPLIES 22

Hi @Kieran Anson ,
Yes everything is in Global scope.
Thanks,
Sam

I tried with sys_ids as well. still its not working.

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Problem is in this line 

con.addQuery('sys_id', userss);

 

userss is sys_id of the logged in user and your GlideRecord is querying customer_contact table so it will have a sys_id of that table and not user record.

 

 

-Anurag

Hi @Anurag Tripathi ,

I am creating user criteria for Contacts that's why I glide the Contact table.

Thanks,
Sam

Im not familiar with that table, does the sys_id of a record on that table is the sys_id of user record?

-Anurag