Populate caller's location on Incidents

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2009 10:40 PM
Very simple client script set to onChange of the Incident Caller field. When the caller is set or changed, the incident location is updated if the caller has a location specified on their profile.
=================================
function onChange(control, oldValue, newValue, isLoading) {
if (oldValue == newValue) {
return;
}
var caller = g_form.getReference('caller_id');
if (caller.location) {
g_form.setValue('location', caller.location);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2018 05:04 AM
Hi,
Try this edited code and this should work.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getReference('caller_id');
if (caller.location) {
var grLoc = new GlideRecord('cmn_location');
grLoc.addQuery('sys_id', caller.location);
grLoc.query();
if(grLoc.next())
g_form.setValue('short_description', grLoc.name);
}
}
Make sure you have given Field name as Caller.
Mark the answer as Correct/Helpful based on its impact.
Thanks,
Archana