To sort out the Name is not empty and Active is true ?

karishmashaik
Kilo Expert

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.

1 ACCEPTED SOLUTION

Martin Ivanov
Giga Sage
Giga Sage

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

View solution in original post

2 REPLIES 2

Martin Ivanov
Giga Sage
Giga Sage

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

Abhijit4
Mega Sage

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.

find_real_file.png

find_real_file.png

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

 

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP