Monday, August 5, 2013

CRM 2011 - Setting the Default View using JScript

We recently had a scenario when we had to set the default value for the look up field when the form gets loaded. Previously it was loaded with Account entity but we had to get it changed to Contact.
 
After checking different blogs I got the answer in different forums. Here is a link to one among them which I referred.
 
document.getElementById("customerid").setAttribute("defaulttype", "2");
Xrm.Page.getControl("customerid").setDefaultView("Guid_for_the_view");

First line of code will set the default type to the Contact entity. Second line will set the lookup view.
 
If we are not using the second line of code, then "My Active Contacts View" or your selected default view will be set.
 
This is one another post which share similar idea on that. You can refer as per your requirement.
 
Hope this helps you.

No comments:

Configuration for CRM Plugins

CRM plugins are always great feature where we can automate many functionality which we cannot automate from user interface. But almost eve...