How to update catalog item fields via client script using getReference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2018 10:16 AM
I have a field on the catalog item called requested_for which is a sys_user reference field.
I want to update the location field on the catalog item to the location of the requested for user - which is not necessarily the current logged in user. I have a catalog client script like below but the req4 is 'undefined' when I print to screen.
How can this be accomplished?
function onChange(control, oldValue, newValue, isLoading) {
if (newValue) {
var req4 = g_form.getReference('requested_for',mycallback);
}
return;
}
function mycallback(req4){
if(!isLoading && newValue != oldValue){
g_form.setValue('requested_for_location', req4.location);
}
}
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2018 01:38 PM
anyway i just tried to check that at my end
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var caller = g_form.getReference('requested_for',mycallback);
function mycallback(caller) {
alert(caller.name);
}
}
And i am able to get the alert with the requester name