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 create query to filter on empty values on a on join "sys_tags" table ?

Maud
Kilo Contributor

Hello Community,

I'm a new developer on Service Portal and I try to create a page which displays a table named "u_location_connectivity". This table is joined on another table "u_location" which is joined on OOB "sys_tags" table.

In my Service Portal page I have a multichoices dropdown list which filters my table on tags. Example :

find_real_file.png

When I want to filter on tags (example "my tag 1") the table displays the expected value. I use this query :

var sitesGr = new GlideRecord("u_location_connectivity");

var queryFilter = "u_location.sys_tags.nameLIKEmy tag 1";

sitesGr.addEncodedQuery(queryFilter);

sitesGr.query();

But when I want to filter on NO TAG (empty/null column) the table displays some rows with tag in addition to those without tag. I use this query :

var sitesGr = new GlideRecord("u_location_connectivity");

var queryFilter = "u_location.sys_tags.nameISEMPTY";

//var queryFilter = "u_location.sys_tagsISEMPTY"; //KO
//var queryFilter = "u_location.sys_tags.nameISEMPTY //KO
//gr.addNullQuery(u_location.sys_tags.name'); //KO
//gr.addNullQuery(u_location.sys_tags'); //KO

sitesGr.addEncodedQuery(queryFilter);

sitesGr.query();

Do you have any idea to get only row with no tag value ?

Best Regards

Maud Garçon

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

please have a look on my article Find all records WITHOUT a tag

Maybe this is what you are looking for.

Maik

Thank you

This made me progress a little, but when I have 2 tags or more it doesn't work...

After filtering my table is :

Col 1Col 2Col 3TagsCol 4
xxxtag1, tag2x
xxx x
xxx x
xxxtag2, tag3x

Do you know which operators can be used on the sys_tags column of a table?

Thank you if you have a better solution.