- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:33 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 07:46 PM
@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.
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 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 04:46 AM
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;
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 05:11 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 05:14 AM
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.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:46 AM
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.
Please mark as helpful & correct answer if it's really worth for you.