Client Script not working

suresh kaliappa
Tera Expert

Hi All , 

 

In sc_req_item table. when we open a form for an existing record then if requested for user is vip then the vip icon should display left to the field. But i tried the script and it was not working. Hence kindly help someone and correct the code if i missed anything. 

 

Note : i unchecked isolate script checkbox. 

 

function onLoad() {
 var callerLabel = $('label.sc_req_item.requested_for');
    if (!callerLabel || !callerField)
        return;
   
    if (!newValue) {
        callerLabel.setStyle({backgroundImage: ""});
        callerField.setStyle({color: ""});
        return;
    }
    g_form.getReference('requested_for', vipCallerCallback);
}

function vipCallerCallback(caller) {
    var callerLabel = $('label.sc_req_item.requested_for').down('label');
    if (!callerLabel || !callerField)
        return;
   
    //check for VIP status
    if (caller.vip == 'true') {
        var bgPosition = "95% 55%";
        if (document.documentElement.getAttribute('data-doctype') == 'true')
            bgPosition = "5% 45%";
           
        callerLabel.setStyle({backgroundImage: "url(images/icons/vip.gif)", backgroundRepeat: "no-repeat", backgroundPosition: bgPosition, paddingLeft: '30px' });
        callerField.setStyle({color: "red"});
    } else {
        callerLabel.setStyle({backgroundImage: ""});
        callerField.setStyle({color: ""});
    }
}