Restrict a select box choice only to specific group on catalog form
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:28 AM
Hi All,
How to restrict a select box choice only to 2 assignment groups on catalog form.
Please assist.
Thanks & Regards.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:39 AM
HI @Joshuu ,
I trust you are doing great.
please find the below code for the same.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var assignmentGroupField = g_form.getReference('assignment_group', restrictGroups); // Replace 'assignment_group' with your field name
function restrictGroups(group) {
var allowedGroups = ['group_sys_id_1', 'group_sys_id_2']; // Replace with the sys_ids of your two allowed groups
if (allowedGroups.indexOf(group.sys_id) === -1) {
g_form.clearValue('assignment_group'); // Clear the field if selected group is not allowed
g_form.showFieldMsg('assignment_group', 'Only specific groups are allowed for selection.', 'error'); // Show an error message
}
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi