Granular Delegation - Delegate User Criteria

Sruthi17
Kilo Sage

I'm setting up Granular Delegation

 

And I wanted to setup Delegate User Criteria

My logic is "Allow to delegate to the current user's reportee"

 

For this I created a new User Criteria and in the script I wrote the below script

(function() {
    answer = false;
    var gr = new GlideRecord('sys_user');
    if (gr.get(current.delegate)) {
        answer = gr.manager == gs.getUserID();
    }
})();


But I get the below error
com.glide.script.RhinoEcmaError: Cannot read property "delegate" from null
User Criteria: 'DutyTravel_DelegateRule' : Line(4) column(0)

Im not sure what I should use in the place of "current.delegate" to check if the logged in user is the manager of the delegate. Need help to solve this. 

Thanks
6 REPLIES 6

Shruti
Mega Sage
Mega Sage

Hi,

Use the script to check whether the user is a manager

var grUser = new GlideRecord('sys_user');
grUser.addActiveQuery();
grUser.addQuery('manager', user_id);
grUser.setLimit(1);
grUser.query();
grUser.hasNext();

Hi @Shruti  ,

Thanks for your reply. This code checks if the logged in user is the manager, then allow to select delegate. But Im trying to achieve is, the logged in user can allow to select only his reportes as delegate person.

Do you know how to achieve this?

Sruthi17
Kilo Sage

Hi @Ankur Bawiskar , @Dr Atul G- LNG @SANDEEP DUTTA , can you provide any heads up on this please?

sorry mate, i have no idea about script.

*************************************************************************************************************
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]

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