- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2022 11:55 PM
Hi All,
I have Requirement , i have a custom user table , form user table i want to sort out the "Name is not empty" and "Active is True" through script .
please help me on this,
thanks,
karishma.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2022 11:58 PM
var grUsers = new GlideRecord('<your custom table name here>');
grUsers.addActiveQuery();
grUsers.addNotNullQuery('<field name which you want not to be empty>')
grUsers.query();
this will return a glide record of the users, filtered by your criteria.
Please Mark Correct AND Helpful. Thanks!
Martin Ivanov
2022 Community Rising Star
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2022 11:58 PM
var grUsers = new GlideRecord('<your custom table name here>');
grUsers.addActiveQuery();
grUsers.addNotNullQuery('<field name which you want not to be empty>')
grUsers.query();
this will return a glide record of the users, filtered by your criteria.
Please Mark Correct AND Helpful. Thanks!
Martin Ivanov
2022 Community Rising Star
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 12:04 AM
Hi Karishma,
You can go to list view of your custom table and apply filter as shown below and right click on filter and click on copy query.
and use below script,
var grUsers = new GlideRecord('custom user table name');
grUsers.addEncodedQuery("paste your copied query here");// query would look something like 'nameISNOTEMPTY^active=true'
grUsers.query();
whille(grUsers.next()){
//Perform your operation here
}
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP