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

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

 

find_real_file.png