Get Inactive users using GlideRecord

varadharaj_a
Kilo Contributor

Hi All,

I would like to get the Manager id of in-active user id. So, to get the "In-active" user using Glide Record, I am using following script

var gr = new GlideRecord('sys_user');

gr.addQuery('sys_id', gs.getUserID());

gr.query();

it return a user data along with his Manager id. But this manager record is as In-Active. So, I would like to get the Manager of this in-active manager. I use below script

but, it does not return any data

var gr1 = new GlideRecord('sys_user');

gr1.addQuery('sys_id', gr.manager);

gr1.query();

if (gr1.next())

{

              gs.addInfoMessage('InActive Mgr:' + gr.name + ':' + gr1.manager);

}

it does not return any Inactive users data.

Is it possible to get any In-active user data using GlideRecord?

Could you please let me know any valuable guidance or suggestions ?

thanks

1 ACCEPTED SOLUTION

Hi



There is a default business rule on the sys_user table called "user query"



It will prevent non admin users from accessing inactive user records


View solution in original post

31 REPLIES 31

Hi Siddartha,



Thanks a lot for your great response.



However, still this "In-Active" user does not bring the data




thanks


Mihir Mohanta
Kilo Sage

Try this script:



var manager = "";


var usr= new GlideRecord('sys_user');


usr.get(gs.getUserID());


if(usr.manager!=""){


if(usr.manager.active==true){


manager = usr.manager.name;


}


else{


manager = usr.manager.manager.name;


}


}


gs.addInfoMessage('Manager of '+usr.name+' is : '+manager);


Sadasiva Reddy
Giga Guru

Hi Varadharaj,



Try this..


var usr = new GlideRecord('sys_user');


usr.addQuery('sys_id', gs.getUserID());


usr.query();


if(usr.next()){


var usr1 = new GlideRecord('sys_user');


usr1.addQuery('sys_id', usr.manager);


usr1.query();


if(usr1.next()){


if(user1.active == 'true')


gs.log('manager is active');


else


gs.log('manager is in-active')'


}


else{


gs.log('manager fields is blank in logged in user record');


}



}



regards,


Sadasiva



Please mark helpful/ correct based on the impact


Hi All,



Thanks a lot for your responses.



However, these scripts only bring the "Active" records, not "In-active" records.


Check it once again.... it brings you in-active records also...


1.


find_real_file.png


2.


find_real_file.png


3.


find_real_file.png



4.


find_real_file.png



regards,


Sadasiva



Please mark helpful/ correct based on the impact