- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 07:59 AM
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 08:15 AM - edited 05-09-2024 08:21 AM
Can you share the script include code? This is an on change script. What field is it on change of? Also by using g_user.UserID() you are passing the logged in users sys_id. So if it is on change of a reference field this will not work.
So I'm thinking that if this is on change and it is based on a field on your form that is a reference to the user table then this line should be var sysid = newValue; //get current user sysid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 08:15 AM - edited 05-09-2024 08:21 AM
Can you share the script include code? This is an on change script. What field is it on change of? Also by using g_user.UserID() you are passing the logged in users sys_id. So if it is on change of a reference field this will not work.
So I'm thinking that if this is on change and it is based on a field on your form that is a reference to the user table then this line should be var sysid = newValue; //get current user sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 08:48 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 08:26 AM
Hi @Shidhi ,
Please correct your glideajax syntex. Your callback function is not correct check below script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var sysid = g_user.userID; //get current user sysid
alert("here = " + sysid);
var ga = new GlideAjax('global.Check_user_group'); //script include name
ga.addParam('sysparm_name', 'getgroup'); //function name
ga.addParam('sysparm_name_sysid', sysid); //passing sysid to server
ga.getXMLAnswer(getGroup);
function getGroup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if (answer == 'true' || answer == true) {
g_form.setReadOnly('domain', true);
} else {
g_form.setReadOnly('domain', false);
}
}
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak