How to update catalog item fields via client script using getReference

Michael M1
Giga Expert

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);
 }


}

15 REPLIES 15

when I type g_form in the editor it provides me with a .addInfoMessage option.

However I changed it to 'alert' and the value is still null. 

It seems like all of my issue are in grabbing the value in requested_for for some reason.

addInfoMessage : my bad you can use both server and client..

just for troubleshoot can you try with below script.

 

function onChange(control, oldValue, newValue, isLoading) {
    
  var caller = g_form.getReference('requested_for',mycallback);


function mycallback(caller) {
    
    alert(caller.name);

}

I get no alert when I do this.

See attached for script screenshot.

 

is it possible if you can share your screen on webex? or google hangout i can try to help you

Than you. I had to go onto other stuff today. 

I only have Skype but may be able to arrange hangout for friday if still willing.