Need to fetch list of users

kulshreshtha
Giga Contributor

I have synced azure ad to servicenow. Now i need to get the list of users present in servicenow. How can this be done using client script?

1 ACCEPTED SOLUTION

yes in servicenow when you create a variable there are different variable types. One is a String type which you are probably using. You can create a reference type and that should do what you are explaining above ^.



find_real_file.png



This is what it will look like on the form



find_real_file.png



if they enter a name that is not in the user table this happens...



find_real_file.png



I believe this is what you are looking for. No need to customize this


View solution in original post

16 REPLIES 16

Nate23
Mega Guru

not sure what exactly you are asking but if you want a query of all user in javascript you use:



var users = new GlideRecord('sys_user');


users.query();


while(users.next()){


//this will iterate through all the users


//insert code here


}



or you can just go to the users tab in the left pane and look at the all the users there. you can export the whole user list into an excel file too.


I am new to javascript. But what I am trying to accomplish is the following. I need create a function so that the query will print all users with gender =male. 

 

var rec = new GlideRecord ('sys_user');

if rec.gender = "male" gs.print('user name'+rec.name);

rec.query();

while 9rec.next() ) {

 gs.print('user name' + rec.name);

 

does this make sense?

 

nayanawadhiya1
Kilo Sage

Hey Naman,



Use GLIDEAJAX in client script for retrieving users.


From Glideajax you can perform server side operations.



Refer this -



GlideAjax - ServiceNow Wiki


Examples of asynchronous GlideAjax


The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: AJAX
 


Visit http://docs.servicenow.com for the latest product documentation