el

Setting default view in the lookup

Thursday, October 17, 2019

Many times we work with lookup in CRM which are showing use view which is default mostly as ‘Active View’. But there are instances when we need to change them to some other views which are more meaningful to the business instead plain ‘Active View’ on load of lookup dialog view. CRM 2011 provide an easy way to achieve this with less trouble to user using JScript as below. Xrm.Page.getControl(lookupfieldname).setDefaultView(viewid); For example Xrm.Page.getControl("customerid").setDefaultView("XXXXXXXX-E6AD-E411-8334-005056AE4312"); So for above example, for the lookup field customer we did set another view as default view based on viewid. You can also set the entities user should see in lookup using JScript as below. document.getElementById(lookupfieldname).setAttribute("defaulttype", objecttypecode); For example document.getElementById("customerid").setAttribute("defaulttype", "1");   or document.getElementById("customerid").setAttribute("defaulttype", "2"); So as you can see here for lookup field customer user has made it compulsory to show records of only 2 entities as account and contact based on object type code. Using fetch xml also user can create set a default view for a lookup but that we will cover some other time. By: Pramod Vilas Zite

No items found.