How to prevent use to submit incident when they selected inactive assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 12:08 AM
Hi ,
we have a requirement, if user selected inactive assignment group, we should prevent then to submit the form.
here due to some other reasons we can't write reference qualifier on assignment group field.
I have written below script include and on submit client script but it is not working as expected .
Can any one help me on this?
Client script :
function onSubmit() {
var group = g_form.getValue('assignment_group');
var ga = new GlideAjax('prevent_incident_submission');
ga.addParam('sysparm_name', "getUserInfo");
ga.addParam('sysparm_assignment_group', group); //Onchange field is reference field to sys_user table
ga.getXML(getgroupname);
function getgroupname(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.addInfoMessage('please select active group');
g_form.clearValue('assignment_group');
}
}
}
****************
Script include :
var prevent_incident_submission = Class.create();
prevent_incident_submission.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo: function() {
var agroup = this.getParameter('sysparm_assignment_group');
var group = new GlideRecord("sys_user_group");
group.addQuery('assignment_group', agroup);
group.addQuery('active', false);
group.query();
if (group.next()) {
var response = group.active.getDisplayValue();
}
return response;
},
type: 'prevent_incident_submission'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 12:22 AM
Hi @rajeevsnow ,
You can create a Business rule like this.
 In When to Run,
-Check Insert or Update
- And in Filter Condition = Assignment Group.Active - is - False
 then in Action
-Add Message
- And check Abort Action
Please mark this helpful and accept my solution if it is helpful.
Regards
Ankit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 12:47 AM
Hello Ankit,
you are correct we can achieve this through Business rule , with business rule it is applying in portal also but users did not want this to run in portal and in business rule with SetAbortAction(true); we are getting OOTB alert' invalid insert' and they don't want, hence i am trying client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 12:50 AM
HI @rajeevsnow ,
I trust you are doing fine.
You can use below code to get the solution for the use case :
Client Script :
function onSubmit() {
var group = g_form.getValue('assignment_group');
var ga = new GlideAjax('prevent_incident_submission');
ga.addParam('sysparm_name', "getUserInfo");
ga.addParam('sysparm_assignment_group', group);
ga.getXML(getgroupname);
function getgroupname(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
g_form.addInfoMessage('Please select an active group.');
g_form.clearValue('assignment_group');
return false;
}
else {
return true;
}
}
}
Script include :
var prevent_incident_submission = Class.create();
prevent_incident_submission.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo: function() {
var agroup = this.getParameter('sysparm_assignment_group');
var response = 'false';
if (agroup) {
var group = new GlideRecord("sys_user_group");
group.addQuery('assignment_group', agroup);
group.addQuery('active', false);
group.query();
if (group.next()) {
response = 'true';
}
}
return response;
},
type: 'prevent_incident_submission'
});
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 01:08 AM
Thank you Amit,
But this is not working.
For both Active and inactive assignment groups , the info message is displaying and in both the cases submission is not stopping .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2023 01:26 AM
hi Rajeev,
as result of the copy action can't you just clear the field if it is inactive? Then the ref qualifier can filter out the inactive ones.
BR,
Barry