2021-07-21 04:40 PM
I am unable to change the font color of a field's label.
In my custom object, I have a reference to the SPAN element (var myElement) which contains field label text.
I validated this by dumping its text and HTML to the console.log.
My code uses the following js which is in the Sys.Application.add_load(function
myElement.style.color = 'red';
No errors occur but the text is still black.
We're running R6.8 P4 HF2 (6.8.00402.1001).
Any help on how to properly set the font color of a field's label would be appreciated.
2021-07-22 04:16 AM - edited 2021-07-22 04:17 AM
<script>
$('#loitem47349').attr('style', 'color: #4169E1 !important');
</script>
And use your own ID instead of loitem47349.
2021-07-22 04:16 AM - edited 2021-07-22 04:17 AM
<script>
$('#loitem47349').attr('style', 'color: #4169E1 !important');
</script>
And use your own ID instead of loitem47349.
2021-07-22 10:21 AM
Thanks Ilya. Is there a good way to get the loitem #. I have the code to look up the fieldid. I want the code to be generic so when migrated to other instances it works without having to change the code. Thanks
2021-07-22 10:24 AM
@NeilGove1, the loitem # is the field id
Advisory Consultant
2021-07-22 10:24 AM - edited 2021-07-22 10:26 AM
My bad
2021-07-22 11:09 AM
Which function returns the correct id of the label? If I use lookupFieldId passing the field name it returns the fieldId but this is not the id used for the field label (in the <SPAN id='loitem ). Is there another function or a way to call lookupFieldId and have it return the label id used with the loitem# ? Again we're on R6.8 P4 HF2. Thanks
2021-07-22 11:25 AM
You just need to combine field ID and prefix 'loitem'.
2021-07-22 11:34 AM
My bad. The loitem is the layout id not the field id.
Use the following to get the loitem number.
$CM._fields[fieldId].layoutId
Advisory Consultant
2021-07-22 12:49 PM
Thanks David. Was able to get it working with your and Ilya's help.
2024-02-13 04:20 AM
For the same requirement i am using the below code but its not working . Could you please help me with it.
<script>
$('#loitem' + $CM._fields[47173].layoutId).attr('style', 'color: #4169E1 !important');
</script>
In above 47173 is my filed id