addnotNullQuery/addNullQuery is not working on GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2023 07:09 AM - edited 02-17-2023 07:12 AM
I have written below background script to check how many records are returned but everytime it is returning count.
In the below script this record has no photo attached so it should return row count as 1 but it is not showing any result.
var user = new GlideRecord('live_profile');
user.addNullQuery('photo');
user.addQuery('sys_id', '566ec9ca83d56ghhbccb3d57709af19fc');
user.query();
if(user.next()) {
var countPA = user.getRowCount();
gs.print("countPA" +countPA);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2023 07:14 AM
HI,
Try this
var usr = new GlideRecord('live_profile');
usr.addNotNullQuery('photo');
usr.addQuery('sys_id', '566ec9ca83d56ghhbccb3d57709af19fc');
usr.query();
gs.print("countPA" +usr.getRowCount());
Since you have queries on a sys_id, the row count will be 1 or 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2023 08:45 AM
I tried but everytime it is returning 1 even if the photo is not there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2023 08:51 AM
Try this
var usr = new GlideRecord('live_profile');
usr.addQuery('photo', '!=', '');
usr.addQuery('sys_id', '566ec9ca83d56ghhbccb3d57709af19fc');
usr.query();
gs.print("countPA" +usr.getRowCount());
If that doesn't work then from the list view of the table filter the record with photo as none or blank or null. And then use that in the encoded query.