How to apply onLoad field style using client script?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 12:42 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 12:45 AM
@saint - is it a reference field?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 12:58 AM
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
Thanks,
Rahul Kumar