How to write User criteria for the catalog item based on the group

poornima batchu
Tera Expert

Hi All, 

I need to create a user criteria to apply it for a catalog item, If the user is a memeber of the group that starts with "Hr_payroll" and the user should not be a part of the "HR_payroll_UK" group.

How should I add this condition in the scriptiing..?

Please help

1 ACCEPTED SOLUTION

David Aldridge
Giga Guru

@poornima batchu if the group names are not going to change frequently, you could try the following to avoid scripting...
Create the User Criteria record with one group to be included, then when you go to edit it, you will see the "Add/Remove multiple" option.

DavidAldridge_0-1701229223367.png

From the Edit Members modal, you can set a filter for "Name starts with HR_payroll" then select all from the left and move to the right. Then remove the two groups you want to exclude back to the left and save. Job done 🙂

DavidAldridge_1-1701229503832.png

 

View solution in original post

6 REPLIES 6

Aman Kumar S
Kilo Patron

You can use isMemberof() function

something like:

if(gs.getUser().isMemberOf("sys_id of the Hr_payroll group") && !gs.getUser().isMemberOf("sys_id of the HR_payroll_UK group")

answer = true;

else

answer = false;

 

Best Regards
Aman Kumar

Hi aman, 

Thanks for your solution.

Here we have so many groups that starts with hr_payroll. So, I need to allow all groups that starts with hr_payroll except Hr_Payroll_UK and HR_Payroll_India groups. 

in that case you need to write up a gliderecord on the user grmember table with encoded query "group.namestartswithhr_payroll"

and using if condition check if any of the group name is Hr_Payroll_UK or HR_Payroll_India then set the answer as false, else true.

 

Best Regards
Aman Kumar

abirakundu23
Mega Sage

Hi @poornima batchu ,

I think create a user criteria & put the group's name that stating with hr_payroll & not put HR_Payroll_UK groups in this User criteria. Below screenshots as your reference & add this User criteria available for in Catalog item.

absnow1_0-1701189837250.png

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