- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:09 AM
Hi,
Am calling script include and getting the filter values as well but not able to set those values in OnChnage client script of Reference(Groups table) variable.
Below is my Onchange script please let me know what.s the issue here?
-----------------------
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:45 AM
@raj99918 Please update the script include script as follows.
var Groupsdata= Class.create();
Groupsdata.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getGroupnames: function(user) {
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user);
gr.query();
while (gr.next()) {
groups.push(gr.group.sys_id);
}
return 'sys_idIN' + groups.toString();
},
type: 'Groupsdata'
});
Also, apply the same reference qualifier again on the Group field in order to make the reference qualifier call the script include.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:14 AM
@raj99918 You can only set one value on a reference field whereas your script is try to set a bunch of sys_ids as values.
It looks like you are trying to restrict your reference field to certain values. This is ideally achieved through reference qualifiers and not using onChange script. I recommend you go through the documentation on reference qualifier here https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/script/server-scripting... and an example here https://www.servicenow.com/community/itsm-articles/reference-qualifier/ta-p/2306509
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:23 AM
Hi @Sandeep Rajput Thanks for your inputs. Yes am trying to restrict the refernce qualifer but when I used this Reference qualifer and it's not working for me below is my qualifer:
javascript: new x_gro_rc_sm.Groupsdata().getGroupnames(current.variables.requested_for.toString());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:37 AM
@raj99918 Please share your Script include code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 04:41 AM - edited 07-24-2024 04:43 AM
SI Code: