Find delegate user user list through background script

Nitya2
Kilo Guru

Hi All,

Kindly let us know background script to get   'user - delegate user'   details , we were having many user having delegations.

kindly let us know to get those in list ?

we have to know their roles also . 'user-delegate-delegate role' details.

kindly help us.

 

1 ACCEPTED SOLUTION

Use this

var gr = new GlideRecord('sys_user_delegate');
//gr.addQuery('user', gs.getUserID());
gr.query();
gs.print('total delegates = '+gr.getRowCount())
if(gr.next()) //use while here if there can be more then 1 entries and youw ant to print all
{
gs.print('User = '+gr.user.user_name + ' has delegate = '+gr.delegate.user_name);
}
-Anurag

View solution in original post

11 REPLIES 11

Try this

var gr = new GlideRecord('sys_user_delegate');
gr.addQuery('user', gs.getUserID());
gr.query();
gs.print('total delegates = '+gr.getRowCount())
if(gr.next()) //use while here if there can be more then 1 entries and youw ant to print all
{
gs.print(gr.delegate.user_name);
}

 

This is what i get with the above script

find_real_file.png

-Anurag

Nitya2
Kilo Guru

Used while multiple records , there many users having delegation but giving 0 results.

 

 

find_real_file.png

You don't have any delegates added to your profile, so that is why you are not getting any result.

The script above is for listing the delegates of THE CURRENT LOGGED IN USER.

Now what is your requirement?

All users that have a delegate?

All the delegates of all the users?

-Anurag

Nitya2
Kilo Guru

we have 100+ users added/updated delegate details ,so i could not able to pull them manually , so i would like to user backgroud scirpt with "user name- user's deleagate name" details

Use this

var gr = new GlideRecord('sys_user_delegate');
//gr.addQuery('user', gs.getUserID());
gr.query();
gs.print('total delegates = '+gr.getRowCount())
if(gr.next()) //use while here if there can be more then 1 entries and youw ant to print all
{
gs.print('User = '+gr.user.user_name + ' has delegate = '+gr.delegate.user_name);
}
-Anurag