The CreatorCon Call for Content is officially open! Get started here.

How to apply onLoad field style using client script?

saint
Tera Expert

Hi Experts,

I'm trying to apply backgroundColor to one of my custom field using OnLoad CS. I tried fetching the control of field as well as element, but the style is not getting applied, can someone please share a sample code of any client script they have created for the same use case.

2 REPLIES 2

Karan Chhabra6
Mega Sage

@saint  - is it a reference field?

Rahul Kumar17
Tera Guru

Hi,

function onLoad() {
var displayControl = g_form.getControl('sys_display.incident.company'); 
g_form.getReference('company', callBack);  
}
    function callBack(ref) {
        if (ref.u_global_corporate_network_firm === 'true') {
            displayControl.style.background = 'red';
        } 
		else {
            displayControl.style.background = '';
        }
    }
}

 

Thanks,

Rahul Kumar

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar