Client script is not able to receive the response from script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 01:18 AM
Hi, I have a requirement in incident form where I have to stop user from adding those groups in assignment group field when there is no member present in that group. So, if group is not having members, then the value should get cleared from incident form's assignment group field. I have made following on change client script for this.
After this I have created the following client callable script include
Ideally when group should be found in group member table then as per the requirement user should be able to retain the group value in assignment group field. Somehow the client script is not able to receive response from script include due to which in all the cases the client script is executing false part and clearing the value. It would be really helpful for me if I get any solution for this. Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 01:30 AM
@kaushiki berter Could you please check the following.
1. Check if your script include is client callable
2. Check if the group sys_id is passed correctly to the script include, add gs.info() statements inside your script include's checkMember method
3. Check if the script include and the client script is in same scope if not then check numerous work script include access is allowed from other application scopes.
4. Add an alert inside your response callback and check what value response variable hold using an alert.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 01:35 AM - edited 02-13-2024 01:36 AM
Hi,
Change your client script Glide Ajax As below
var ga = new GlideAjax('<Script Incliude Name>');
ga.addParam('sysparm_name','<Function Name>');
ga.addParam('sysparm_user_name','<group value>');
ga.getXMLAnswer(ManagerParse);
}
function ManagerParse(response) {
//Add the return logic here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 01:36 AM
Hey @kaushiki berter ,
I think your query is incorrect here, try changing
gr.addQuery('group', gp);
TO
gr.addEncodedQuery('group.sys_id=' + gp);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 01:49 AM
Hello @kaushiki berter ,
Please give a try to the modified code below and see how it works for you.
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gpName = g_form.getValue("assignment_group");
var ga = new GlideAjax('<Script Include Name>');
ga.addParam('sysparm_name', 'checkMember');
ga.addParam('sysparm_group', gpName);
ga.getXMLAnswer(ManagerParse);
}
function ManagerParse(response) {
if (response === 'yes') {
// Do nothing, let the assignment_group value remain
alert('true');
} else {
alert('false');
alert(gpName);
g_form.clearValue('assignment_group');
}
}
Script Include:
var numerous_work = Class.create();
numerous_work.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkMember: function() {
var gp = this.getParameter('sysparm_group');
var gr = new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('group.sys_id=' + gp);
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
},
type: 'numerous_work'
});
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket