- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 01:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 12:20 AM
Hello @RamcharanA, I'm not sure why you'd like to go for this approach when there are better approaches, highlighted earlier, available. Nevertheless, here are the SI and CS as asked:
- Script Include: ensure its client callable as depicted below
Here is the script to be used in SI
var TestRestrictChangeInactiveAssignedGroup = Class.create();
TestRestrictChangeInactiveAssignedGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
inactiveGroupCheck: function(){
var assignedGroup = this.getParameter('sysparm_assignedGroup');
var grGroup = new GlideRecord('sys_user_group');
grGroup.get(assignedGroup);
grGroup.addActiveQuery();
grGroup.query();
return grGroup.hasNext();
},
type: 'TestRestrictChangeInactiveAssignedGroup'
});
- Client Script: its configured to run only for new record, if you wish to run it for existing Change too then remove the first if condition
Here is the script to be used
function onSubmit() {
//Runs only for new record
if (g_form.isNewRecord()) { // remove if condition here if to be run for update too
var gaAssignedGroup = new GlideAjax('TestRestrictChangeInactiveAssignedGroup');
gaAssignedGroup.addParam('sysparm_name', 'inactiveGroupCheck');
gaAssignedGroup.addParam('sysparm_assignedGroup', g_form.getValue('assignment_group'));
gaAssignedGroup.getXMLWait(); // doesn't work in portal
var isActiveGroup = gaAssignedGroup.getAnswer();
if (isActiveGroup === 'false') {
g_form.addErrorMessage('Selected Group is inactive');
return false;
}
}
}
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2025 12:20 AM
Hello @RamcharanA, I'm not sure why you'd like to go for this approach when there are better approaches, highlighted earlier, available. Nevertheless, here are the SI and CS as asked:
- Script Include: ensure its client callable as depicted below
Here is the script to be used in SI
var TestRestrictChangeInactiveAssignedGroup = Class.create();
TestRestrictChangeInactiveAssignedGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
inactiveGroupCheck: function(){
var assignedGroup = this.getParameter('sysparm_assignedGroup');
var grGroup = new GlideRecord('sys_user_group');
grGroup.get(assignedGroup);
grGroup.addActiveQuery();
grGroup.query();
return grGroup.hasNext();
},
type: 'TestRestrictChangeInactiveAssignedGroup'
});
- Client Script: its configured to run only for new record, if you wish to run it for existing Change too then remove the first if condition
Here is the script to be used
function onSubmit() {
//Runs only for new record
if (g_form.isNewRecord()) { // remove if condition here if to be run for update too
var gaAssignedGroup = new GlideAjax('TestRestrictChangeInactiveAssignedGroup');
gaAssignedGroup.addParam('sysparm_name', 'inactiveGroupCheck');
gaAssignedGroup.addParam('sysparm_assignedGroup', g_form.getValue('assignment_group'));
gaAssignedGroup.getXMLWait(); // doesn't work in portal
var isActiveGroup = gaAssignedGroup.getAnswer();
if (isActiveGroup === 'false') {
g_form.addErrorMessage('Selected Group is inactive');
return false;
}
}
}
Regards,
Nishant