Create user criteria for Group managers

Community Alums
Not applicable

Hello,

We need to make the catalog item visible to the users who are group managers in sys_user_group table.

Any thoughts?

Thanks

9 REPLIES 9

Bhavya11
Kilo Patron

Hi @Community Alums ,

 

Create Script include getManger

script 

 

var getManger = Class.create();
getManger.prototype = {
    initialize: function() {
    },
	canEditOwnershipGroup : function(){
		var sys_usrgroup = new GlideRecord("sys_user_group");
		sys_usrgroup.addQuery("manager",gs.getUser().getID());
		sys_usrgroup.query();
		if(sys_usrgroup.hasNext()){
			return true;
		}else{
			return false;
		}
	},

    type: 'getManger'
};

 

 

User criteria

answer = new getManger().canEditOwnershipGroup();
 
Bhavya11_0-1729748158093.png

 

then add to catalog item

Bhavya11_1-1729748181232.png

Please mark helpful & correct answer if it's really worthy for you.

 

Thanks,

BK

 

 

anshul_goyal
Kilo Sage

Hi @Community Alums,

You can try the following steps in the User Criteria script:

  1. Click the NEW button in the Available for related list.
  2. Check the Advanced checkbox.
  3. In the script section, use the code below:
var groupRef = new GlideRecord('sys_user_group');
if (groupRef.get('manager', user_id)) {
	answer = true;
} else {
	answer = false;
}


Please mark my solution as Helpful and Accepted, if it works for you in any way!

Thanks

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Community Alums ,

 

You can create a new User Criteria that grants access exclusively to the group manager.

Please use the following code in the user criteria script to ensure that only the group manager can access the item.

 

var grpManager = new GlideRecord('sys_user_group');
grpManager.addActiveQuery();
grpManager.addQuery('manager', gs.getUserID());
grpManager.query();
if (grpManager.hasNext()) {
    answer = true;
} else {
    answer = false;
}

 

MoinKazi_0-1729749575655.png

 

After that, you can add this User Criteria to the "Available For" related list in your catalog item.

 

[Note- If it still doesn't work, try clearing the cache using cache.do in the filter navigator, as it may take some time to apply changes.]

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Community Alums
Not applicable

Hello,

I tried above answers . But they are not working for me.

I have following record in "sys_user_group"  table. But Catalog item is not visible to "Jacinto Gawron" after impersonation.

LexaHunger_20_0-1729750896102.png