- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 12:27 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 12:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:29 PM
In the above script remove quotation for false..
doThis(gs.getUserID());
function doThis(user){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',user );
gr.query();
if(gr.next())
{
if(gr.manager != ''){
if(gr.manager.active!=false)
{
gs.print('manager is active' +gr.manager.name);
}
else{
doThis(gr.manager);
}
}
else{
gs.print('manager field is blank in User '+gr.manager.name+' record');
}
}
}
Regards,
Sadasiva
Please mark helpful/ correct based on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:32 PM
one more change..
else{
gs.print('manager field is blank in User '+gr.name+' record');
}
Regards,
Sadasiva
Please mark helpful/ correct based on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:39 PM
Hi,
I have used your query with little modification as below. I use it in "Script Include".
------------------------------------------------------------
doThis(gs.getUserID());
function doThis(user){
var text='User Name: ';
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',user );
gr.query();
gs.addInfoMessage('query with ' +user);
if (gr.next())
{
if(gr.manager != '')
{
if(gr.manager.active!=false){
gs.addInfoMessage('login user mgr' +gr.manager.getDisplayValue());
}
else{
doThis(gr.manager);
}
}
else
{
gs.addInfoMessage('manager field is blank in User '+gr.manager.name+' record');
}
}
}
function getUserInfo(sysid)
{
gs.addInfoMessage('Usr:' + sysid);
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', sysid);
gr.addActiveQuery();
gr.query();
if (gr.next())
return gr;
}
-------------------------------------------------------
while running this app, I am getting following "undefined" for the "In-Active" records.
It does not bring the Manager of in-active user.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 10:48 PM
my question is from where did you call function getUserInfo(sysid) and where did you defined sysid..
regards,
sadasiva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 12:08 AM
Hi Siva,
Actually, as admin, when I try it, it is working. If I impersonate as non-admin user, it is not working. Even I set ITIL role to that non-admin user, it does not bring the data.
thanks