client script to validate glide list field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 07:43 AM
i have scenario to make the field mandatory on change of the assignment group on INC table based on the below condition
there is a glide list field on group table referring to sys_user_group_list table which may have more than one comma separated values.
if the glide list field matches the specific vale on change of the assignment group field value on INC form , then make the field required field mandatory
i have tried creating onChange client script and Script include to achieve this but still finding an issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 07:58 AM
Can you share the script your tried?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 01:42 AM
Client Script below

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 07:21 AM
So you are just looking for one specific group being in the list of groups? If so you can just do a onChange script and use indexOf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2024 07:30 AM
you can try bellow sample script to resolve your issue:
Script include:
// Script Include: CheckGroupValues
var CheckGroupValues = Class.create();
CheckGroupValues.prototype = {
initialize: function() {},
isGroupMatched: function(assignmentGroupSysId) {
var matched = false;
// GlideRecord to check the specific Glide List field on the group table
var groupGr = new GlideRecord('sys_user_group');
if (groupGr.get(assignmentGroupSysId)) {
// Assuming 'u_glide_list_field' is your Glide List field
var glideListValues = groupGr.u_glide_list_field.split(',');
// Check for the specific value you're looking for
for (var i = 0; i < glideListValues.length; i++) {
if (glideListValues[i].trim() === 'specific_value') { // Replace 'specific_value' with your value
matched = true;
break;
}
}
}
return matched;
},
type: 'CheckGroupValues'
};
onChange Client script:
// onChange Client Script for the Assignment Group field
function onChange(control, oldValue, newValue) {
if (newValue) {
// Create a GlideAjax object
var ga = new GlideAjax('CheckGroupValues');
ga.addParam('sysparm_name', 'isGroupMatched');
ga.addParam('sysparm_assignment_group', newValue);
// Call the Script Include
ga.getXMLAnswer(function(response) {
if (response === 'true') {
// If matched, make the field mandatory
g_form.setMandatory('field_name', true); // Replace 'field_name' with the actual field name
g_form.showFieldMsg('field_name', 'This field is mandatory because the assignment group is set.', 'error');
} else {
// If not matched, remove the mandatory requirement
g_form.setMandatory('field_name', false);
g_form.hideFieldMsg('field_name');
}
});
}
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh