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

Yes Anurag, contact is the child table of User table.
Thanks,
Sam

Can you show the user record where name is this

names == "ABC, XYZ")

 

Why are you checking name when you can just check the sys_id for a couple of names

 

-Anurag

I checked with sys_id/s as well. but no luck😑

The name that you care comparing it to, 'ABC, XYZ', i understand it is an example you have given here, but to test can you hardcode it to a particular value and test to be sure. 

Maybe remove that condition completely to see if the glide record is comin i the if con.next() block

 

Something like

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();
         answer = true;
  }
else{
 answer = false;
}
-Anurag

Yes for particular business line it is working.
If I am giving below condition, its working as expected.

if (names == "ABC"){
answer= true
}
..............

 

Thanks,
Sam