Hide lookup fields on a crmForm

Hiding a field and caption can normally be done by setting the display property of the control to none.

crmForm.all.new_customfield.style.display = “none”;
crmForm.all.new_customfield_c.style.display = “none”;

The _c extensions specifies the caption of the field.
In case of a lookupfield the above code won’t work bacause the “new_customfield” points to the lookup button and not the textbox.

Another way to hide fields and captions it to hide the TD tag that is wrapped arround it. This will work for all types of fields.

crmForm.all.new_customfield_d.style.display = “none”;
crmForm.all.new_customfield_c.style.display = “none”;

_d meaning the data field (the textbox) and _c meaning caption.


Tagged with: ,
Posted in CRM 4
2 comments on “Hide lookup fields on a crmForm
  1. Zsofia says:

    Hi, I need to hide few Lookup buttons on the OnLoad() and let those fields and their text boxes display properly, but without Lookup button in Certain Cases and With Lookup button in some other cases. I should be able to save data properly from those Text Fields, after disabling the Lookups. How do I achieve this?

  2. kennyvaes says:


    If you only want to hide te button of the lookup then you would need to use the field name instead of the _d or _c. Say you want to hide the Primary Contact lookup button on an account then you would use:
    crmForm.all.primarycontactid.style.display = “none”;

    And since the lookup will autoresolve it should save properly. If it is not set to auto resolve then you would have to construct your own LookupItem and fill in the ID, value and entityname.

    To create a lookupcontrol item have a look at this post: http://blog.alistairl.org/archive/2008/09/02/3870.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: