- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2019 10:12 AM
I have a requirement based on work we did on the New Call module (we are transitioning to Agent Workspace). We have an onChange client script that fills a custom field (u_workstation) which looks up the caller ID from the cmdb table and fills it, if it is empty. This works perfectly on the New Call, and even works on the platform version (default view) of Interaction records. *I have tried this as Mobile/Service Portal and All, with no change in behavior
**Additional note: on New Call the user field is called 'caller' instead of 'opened_for' but otherwise these scripts are identical.
function onChange(control, oldValue, newValue, isLoading) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
//check to see if we have a workstation listed
var ci = g_form.getValue('u_workstation');
if(ci == ''){
var user = g_form.getValue('opened_for'); //get the current user
var gr = new GlideRecord('cmdb_ci_computer'); //Table your computers reside in
gr.addQuery('assigned_to', user);
gr.query();
if(gr.next()){
g_form.setValue('u_workstation', gr.sys_id);
}
}
}
}
}
Solved! Go to Solution.
- Labels:
-
Service Desk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2019 08:06 PM
If I recall correctly, Agent workspace should work exactly like SP scripts. Meaning that you can't just do a GlideRecord call that way. Really you should probably be doing a glideAjax call but.. this should get it working.
function onChange(control, oldValue, newValue, isLoading) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
//check to see if we have a workstation listed
var ci = g_form.getValue('u_workstation');
if(ci == ''){
var user = g_form.getValue('opened_for'); //get the current user
var comp = new GlideRecord('cmdb_ci_computer');
comp.addQuery('assigned_to', user);
comp.query(function(compRec){
if(compRec.next()){
g_form.setValue('u_workstation', compRec.sys_id);
}
});
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2019 08:06 PM
If I recall correctly, Agent workspace should work exactly like SP scripts. Meaning that you can't just do a GlideRecord call that way. Really you should probably be doing a glideAjax call but.. this should get it working.
function onChange(control, oldValue, newValue, isLoading) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
//check to see if we have a workstation listed
var ci = g_form.getValue('u_workstation');
if(ci == ''){
var user = g_form.getValue('opened_for'); //get the current user
var comp = new GlideRecord('cmdb_ci_computer');
comp.addQuery('assigned_to', user);
comp.query(function(compRec){
if(compRec.next()){
g_form.setValue('u_workstation', compRec.sys_id);
}
});
}
}
}
}