How to create query to filter on empty values on a on join "sys_tags" table ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2022 08:38 AM
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 :
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
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2022 10:13 AM
Hi
please have a look on my article Find all records WITHOUT a tag
Maybe this is what you are looking for.
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2022 07:11 AM
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 1 | Col 2 | Col 3 | Tags | Col 4 |
x | x | x | tag1, tag2 | x |
x | x | x | x | |
x | x | x | x | |
x | x | x | tag2, tag3 | x |
Do you know which operators can be used on the sys_tags column of a table?
Thank you if you have a better solution.