We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Granular Delegation - Delegate User Criteria

Sruthi17
Mega 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
Giga 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
Mega Sage

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

sorry mate, i have no idea about script.

*************************************************************************************************************
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/dratulgrover [ Connect for 1-1 Session]

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