User Criteria - Granting Managers Access Based on Their Employees

EmreA
Tera Contributor

Hey everyone,

I'm setting up a User Criteria where a manager should get access to a catalog item or kb articles but lets start with catalog items only if least one of their direct reports has access to that specific item.

I’ve already set up a loop that goes through the manager’s employees, but I’m stuck on how to check if those employees have access to the catalog item.

Key Questions:

  1. How do I check if an employee has access to a specific catalog item inside the loop?
  2. Is there a better way to achieve this in User Criteria, or should I use another method?

Any advice would be greatly appreciated! Thanks in advance! 

answer = checkIfManager();

function checkIfManager() {
    var gr = new GlideRecord('sys_user');
    gr.addActiveQuery();
    gr.addQuery('manager', user_id); // user_id is set by User Criteria
    gr.query();

    while (gr.next()) {
        // Loop through employees, do nothing for now
}

    return false; // Just a placeholder return
}

will this post help me? 
https://www.servicenow.com/community/developer-forum/requirement-to-check-if-the-user-have-access-to...

0 REPLIES 0