How to change the text color of a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2022 10:45 AM
Hello everyone,
I'm having the following problem:
I have to change the field color to red when the user is VIP.
But I'm not getting it, I've already created the style and the client script, but I can't change it, neither in the form nor in the table.
If you can help, thank you very much
Style:
javascript:current.opened_by.vip==true
background-image: url('images/icons/vip.gif');
background-repeat: no-repeat;
color:red;
I've tried by client script but I can't change
function onLoad() {
//Type appropriate comment here, and begin script below
var element = g_form.getElement('current.opened_by.vip');
if (element == True) {
element.style.color = "red";
}
}
Note: I don't know if that could be the reason, but this field is for the global application, I'm having to create this change in the human resources application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2022 09:24 PM
try this:
function onLoad() {
var element = g_form.getControl('<field_name>');
element.style.backgroundColor = "rgb(255,0,0)";
}
note: you can't set field colour to a different table. So, dot-walking would not work in the '<field_name>'.
In addition, if condition logic should be in the below format -
if(element == 'true')
Regards,
Snehangshu Sarkar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2022 10:08 PM
Hi,
Please check below link:
you can use something like this:
var caller = g_form.getReference('caller_id',callback);
function callback(caller){
if(caller.vip == 'true'){
var labelcolor = document.getElementById('label.incident.caller_id');
labelcolor.style.color = 'red';
}
}
Thanks,
Anil Lande
Thanks
Anil Lande