As you know, CRM automatically adds a field label/description to any field on the data entry form ( as shown below ):
Occasionally, I have run into the requirement to hide the field label. This is easily done by unchecking the Display label on the form property of the field:
Unfortunately, this produces what I think is an undesirable result:
Want I really want is to have the actual edit field to remain where it was originally, lined up with the other edit fields. So, how do we get around this functionality? With a little ingenuity and JavaScript, of course.
Add the following line to the Form's OnLoad event:
crmForm.all.[fieldname]_c.style.color = "#EEF0F6";
All field labels are named exactly like the data entry fields, but with a "_c" appended to the end of the name.
In this example, we are changing the color of the text of the field label to match the Form's background color. This will, in effect, "hide" the label from the user, while keeping the form layout the same. Here is how it will actually look:
Pretty cool, huh?
NOTE: I found the color information used in this example by reviewing the sample stylesheet that is included with the CRM 3.0 SDK.
Update (2/18/06):
Ryan Farley has a great article that shows a similar technique for hiding an entire field.
2 Responses
Mitch Milam’s Microsoft Discussions » Blog Archive » Changing Label Attributes on a MSCRM 3.0 Form
16|Feb|2006 1[...] Hiding a Form Field Label in MSCRM 3.0 [...]
Changing Label Text at Runtime - CRM Developer
14|Apr|2008 2[...] change labels if needed to match things that are happening on the form. This could also be used to hide labels altogether as well. Tags: MSCRM, Client Scripting What's This? Print |  Send |  [...]
Leave a reply