- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 05:25 PM
I have a user select box on which there is a on change which would load the location, phoen number etc. It works in the platform view but not on the Service Operations workspace.
Both Isolate script is checked true and UI type is set to "All"
Following is the code. any pointers appreciated.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
var userSysId = newValue;
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
// If the user record is found, populate the location and phone number fields
g_form.addInfoMessage("inside");
g_form.setValue('location', userGR.getValue('location'));
g_form.setValue('u_business_phone',userGR.getValue('phone'));
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 12:47 AM
Hi @gnewuser
We can't do a Glide Query through a client script directly, you need to make use of GlideAjax or g_form.getReference() APIs to achieve this. Refer below post and set it up :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 08:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 08:36 PM
Hi @gnewuser ,
you can try something like below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var caller = g_form.getReference('caller_id', getCallerInfo);
function getCallerInfo(caller) {
alert("inside");
g_form.setValue('description', caller.email);
g_form.setValue('location', caller.location);
g_form.setValue('business_phone', caller.phone);
}
}
Note :Gliderecord should not be used in client side scripting and can be easily replaced/remodeled using a script include + Glideajax
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 08:43 PM - edited 08-01-2024 08:44 PM
@gnewuser Direct GlideRecord queries are not supported on Service Portal and Workspace client script, you need to use GlideAjax/g_form.getReference to replace the following code
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
Please refer to https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0694090 to know more about this topic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 12:47 AM
Hi @gnewuser
We can't do a Glide Query through a client script directly, you need to make use of GlideAjax or g_form.getReference() APIs to achieve this. Refer below post and set it up :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.