var ReferenceQualifierHelper = Class.create(); ReferenceQualifierHelper.prototype = { backfillAssignmentGroup: function() { var company = current.company; var assigneeGroupsQualifier = ''; // Define the groups to be presented when the company is 'Y' var YGroups = [ 'X Call Desk Agent', 'X First Line Agent', 'Field Services of X Lux', 'Field Services of X Sgp', 'Field Services of X Lie', 'IT & Security governance', 'Field Services of Y' ]; // Filter groups based on your criteria (e.g., specific groups when company is 'Y') var grGroups = new GlideRecord('sys_user_group'); if (company && company == 'Y') { grGroups.addQuery('name', 'IN', YGroups); } else { // Default behavior: include all groups when company is not 'Y' grGroups.addNotNullQuery('sys_id'); } grGroups.query(); while (grGroups.next()) { if (assigneeGroupsQualifier.length == 0) { assigneeGroupsQualifier = 'sys_idIN' + grGroups.getUniqueValue(); } else { assigneeGroupsQualifier += (',' + grGroups.getUniqueValue()); } } gs.log('DP: RefQual = ' + assigneeGroupsQualifier); return assigneeGroupsQualifier; }, type: 'ReferenceQualifierHelper' };