how to write background script that will give you list of user whose location is empty

kusumgautam
Tera Contributor
 
1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

You can create the query from the user list view and then use in a script

 

For ex

 

var user = new GlideRecord('sys_user');
user.addEncodedQuery('locationISEMPTY');
user.query();

while (user.next())
{
   gs.info('Location is empty for '+user.user_name);
}

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @kusumgautam 

 

You can try with list view

 

LearnNGrowAtul_0-1701885143552.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

SanjivMeher
Kilo Patron
Kilo Patron

You can create the query from the user list view and then use in a script

 

For ex

 

var user = new GlideRecord('sys_user');
user.addEncodedQuery('locationISEMPTY');
user.query();

while (user.next())
{
   gs.info('Location is empty for '+user.user_name);
}

Please mark this response as correct or helpful if it assisted you with your question.

You are killing it, man. Awesome.

I wish i know coding.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Thanks @Dr Atul G- LNG  :). 


Please mark this response as correct or helpful if it assisted you with your question.