Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set the font color for the field Label

NeilGove1
Contributor III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Ilya_Khen
Champion III

NeilGove1,

 

<script>
	$('#loitem47349').attr('style', 'color: #4169E1 !important');
</script>

 

And use your own ID instead of loitem47349.

View solution in original post

10 REPLIES 10

Ilya_Khen
Champion III

NeilGove1,

 

<script>
	$('#loitem47349').attr('style', 'color: #4169E1 !important');
</script>

 

And use your own ID instead of loitem47349.

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

@NeilGove1, the loitem # is the field id

 Advisory Consultant

Ilya_Khen
Champion III

My bad The code David provided will work exactly as you need as returning field ID needed in this case.

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

 

Ilya_Khen
Champion III

You just need to combine field ID and prefix 'loitem'.

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

Thanks David. Was able to get it working with your and Ilya's help.

@DavidPetty @Ilya_Khen 

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