querying a document id field type

yundlu316
Kilo Guru

Hi Everyone, I have a knowledge base hierarchy that looks something like this:

Benefits

        Medical

        Dental

        Life Insurance

I want to write a query where I filter the kb_category by the parent_id so that it returns all articles in the general Benefits category.   I've written the following, but it does not work:

ka.addQuery('kb_category.parent_id', 'f939ebf6db25ba00179c73abbf9619ba');

I noticed that the type for parent_id is document_id and I read somewhere that those types of variables cannot be dot-walked.   Is there another way where I can filter my query to just have parent_id = Benefits?

Thanks.

ka.addQuery('kb_category.parent_id', 'f939ebf6db25ba00179c73abbf9619ba');

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello David,



You should be able to dot-walking to parent_id. I just created a sample script and it worked fine.


Sample


var gr = new GlideRecord('kb_knowledge');


gr.addQuery('sys_id','e97ee81eff6002009b20ffffffffffe0'); //Hardcoding sys_id for testing purpose


gr.query();


while(gr.next())


{


gs.addInfoMessage(gr.kb_category.parent_id);


}


View solution in original post

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello David,



You should be able to dot-walking to parent_id. I just created a sample script and it worked fine.


Sample


var gr = new GlideRecord('kb_knowledge');


gr.addQuery('sys_id','e97ee81eff6002009b20ffffffffffe0'); //Hardcoding sys_id for testing purpose


gr.query();


while(gr.next())


{


gs.addInfoMessage(gr.kb_category.parent_id);


}


Hey Pradeep, thanks for your help.   I didn't change any of my code, but I logged out and logged back in and now the code works.   Super strange stuff...