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

Ankur Bawiskar
Tera Patron
Tera Patron

@Sruthi17 

Can you explain what's your business requirement?

where are you writing that script?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thanks for your response.

I'm working on granular delegation.

I've setup a delegation rule.

I've setup Delegator User Criteria- Allow only managers to delegate this rule

Im now working on setting up Delegate User Criteria- Allow the manage to delegate to his/her reporte only. 

 

 

Sruthi17_0-1752643485460.png

Test Cases: 

Sruthi17_2-1752643639344.png