Alternate Title: How to hide the “New” or “Properties” button from the CRM 2011 Lookup Dialog.
Following on the heels of yesterday’s post, I have finally discovered a way to eliminate the pesky “New” and “Properties” buttons from the Lookup dialog. This was, again, easier accomplished in the previous version of CRM, with the following code:
1: crmForm.all.<lookup>.AddParam("ShowNewButton", 0);
Here’s the new way to hide the “New” button:
1: var lookupControl = Sys.Application.findComponent("some_lookupid");
3: if (lookupControl != null)
5: lookupControl._element._behaviors.AddParam("ShowNewButton", 0);
Like most of the things on this blog, this is highly unsupported, but I personally believe that this is a harmless hack. There is one caveat, however, to the above code:
- The ‘_behaviors’ member is a collection of references to classes. For every Lookup I could find, there was only one entry, and it exposed the “AddParam” function. Conceivably, there could be other Lookups with multiple behaviors, and the first item in ‘_behaviors’ may not be the one you want. You have been warned.