Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use script on Virtual Agent to filter table "sc_cat_item" by "reference type" field -> Category?

Junyu
Tera Contributor

Dear all,

I tried to use the filter like "category contains Navigation" in the sc_cat_item and no records were found:

image

image

Then I used "gr.addEncodedQuery('categoryLIKENavigation')" in  Scripts of the "Reference Choice" node in Virtual Agent:

image

image

 

But it can show me 4 records and they really belong to the category of Navigation:

image

image

 

The current problem is that the results displayed by the query in the table and the Virtual Agent query are inconsistent. I know the reason is that Category is a field of type "reference".
So I want to know how to write Scripts so that the results on the Virtual Agent are consistent with the query results of the sc_cat_item table.

thank you very much.

6 REPLIES 6

Hi,

in your background script you are not adding the query for Navigation title

regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

I tried again, in sc_cat_item, no record:

find_real_file.png

Then in script-background:

find_real_file.png

find_real_file.png

It has four records.

 

The numbers are still inconsistent, what's the reason?