User Criteria for a Catalog Item

Ashwin Ganesh
Tera Contributor

Hello All,
I want my catalog item should be available only to a particular group and for users who are managers. I am trying to use my Available for and Not available for my catalog item but it was not working as expected. Can anyone pls guide me on this user criteria inorder to restrict my catalog.

My catalog item should be available only to users who are manager and for one particular group(EG:hardware).

 

Thanks in advance...

1 REPLY 1

Aniket Chavan
Tera Sage
Tera Sage

Hello @Ashwin Ganesh ,

Please give a try to the script below and see how it works for you and add your group in the groups field.

checkCondition();
answer = ifScript();

// Your comments go here (metadata)

function ifScript() {
    // Get the current logged-in user
    var currentUserID = gs.getUserID();

    // Query the sys_user table for records where the current user is listed as a manager
    var userGr = new GlideRecord('sys_user');
    userGr.addQuery('manager', currentUserID);
    userGr.query();

    // Check if any records were found
    if (userGr.hasNext()) {
        return 'true'; // User is a manager, grant access
    } else {
        return 'false'; // User is not a manager, restrict access
    }
}

 

AniketChavan_0-1706735085943.png

 

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket