Getting Undifened in a field

hema sundar
Tera Contributor

Hello community i have written a client script to set value of field from  a reference field but i am getting undefined in that  field . Here is the script 


ar getOEM = g_form.getReference('vendor', setTeamandCategory);
function setTeamandCategory(getOEM) {
if (getOEM)
g_form.setValue('u_team_category', getOEM.u_team_category);
g_form.setValue('contract_administrator', getOEM.contact);
}

 

hemasundar_0-1703748748644.png

 

6 REPLIES 6

If i select OEM field it is working fine but if i remove value from the OEM field it is showing undefine 

Hi @hema sundar , If your onChnage client script runs on the OEM field, can you try the below script?

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (newValue != '') {
        var getOEM = g_form.getReference('vendor', setTeamandCategory);

        function setTeamandCategory(getOEM) {
            if (getOEM)
                g_form.setValue('u_team_category', getOEM.u_team_category);
            g_form.setValue('contract_administrator', getOEM.contact);
        }
    } else {
        g_form.clearValue('u_team_category');
        g_form.clearValue('contract_administrator');
    }
}
 
Regards,
Sunil