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

NitheeshkuS
Tera Contributor

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)

Hi @NitheeshkuS ,
logs are not working on the User criteria dont know why. Yes i used sys_id but still not working.
Thanks.
Sam

Samiksha2
Mega Sage

Hi All,

I am still struggling with the script. Please help me here.

Thanks.
Sam

AntoniZ99967320
Kilo Sage

What is the value the "userss" variable?

Are there any results returned after executing the con.query();

Hi @AntoniZ99967320 ,

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