DisableViewPicker not working in CRM 2013

In CRM we are often faced with the requirement of disabling the view picker of a lookup view.
Say we a have a lookup field called customerid on the form of another entity  and on click of the lookup, we need to disable the view selector of the lookup view window.
In Crm 2011 this could be achieved with the following code
$(“#customerid”).attr(“disableviewpicker”, “1”)
However in CRM 2013, you might find the  code above not working as expected. To do the same in CRM 2013, the trick is not find the image of the particular lookup field and  apply the code to the image tag.
$(“#customerid”).find(“img”).attr(“disableviewpicker”, “1”)
Hope this helps!

7 thoughts on “DisableViewPicker not working in CRM 2013”

  1. Why would you want to use unsupported code to do this, when you can set the properties of the lookup field on the form to restrict the view selection to one or several views, or lock it completely? And of course you can set this to different view(s) for different versions of the form, if that is useful.

    1. Hi,
      Absolutely I agree to your point. However there are scenarios when selection of views are not available for the lookup field. Take an example of the customerid field in the opportunity entity where the lookup entity type can be of type account or contact and your business requirement would require you to restrict users to only account entity views. Here for the customerid lookup field you cannot configure OOB.
      Also similar is the case with the From lookup of the email. Actually in CRM, we do not have options for view selection of the the lookup fields when the field if of type multi entity.
      There i have found this code to be very useful.

      1. Ah, OK, I guess that makes sense. Also probably why some of the Customer fields are being replaced (slowly) by separate Account and Contact (eg on Opportunity), to avoid having to resort to this sort of thing.

    1. Hi Thanks for reading my blog. I tried it both in Crm on-premise and online and it works for me.
      Please note that this trick is required only for multi entity lookup. if you have single entity lookup, disabling view picker is achievable OOB.
      If you are looking at multientity lookup only, for an alternative you can try the following:
      $(“#customerid_i”).attr(“disableviewpicker”, “1”)
      Let me know if this works for you.

  2. you can also disable it in customization, by selecting “View selector” as off

    1. Hi,
      Agreed. However there are scenarios when selection of views are not available for the lookup field. Take an example of the customerid field in the opportunity entity where the lookup entity type can be of type account or contact and your business requirement would require you to restrict users to only account entity views. Here for the customerid lookup field you cannot configure OOB.
      From 2016, however this is made easy as the customerid is slowly replaced by the Account and Contact field

Comments are closed.