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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

in your script in Virtual agent dot walk to title

gr.addEncodedQuery('category.titleLIKENavigation');

regards
Ankur

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

Hi @Ankur Bawiskar ,

I tried:

find_real_file.png

But the problem of inconsistency still exists:

find_real_file.png

find_real_file.png

Please tell me what to do next. Thank you.

Hi,

The table filter is not working for admins or non-admins?

Did you try to run background script and verify the count?

Regards
Ankur

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

Hi @Ankur Bawiskar 

I am the admin and I just tried the two places.

I also can't see the "Navigation" Category in the background table.

So I think Virtual Agent retrieves more results (but I don't know where these results come from)

 

And I tried in script-background:

find_real_file.png

find_real_file.png

It's too much, sc_cat_item has only 41 records in total:

find_real_file.png

Please help me to locate the problem, thank you.