CRM 2016 set default “Look for” entity and “Look in” view when using “Look Up Record” dialog

Dynamics CRM 2013 to 2015 we are able to set the default “Look for” entity and “Look in” view of the “Look Up Record” dialog using the following:

document.getElementById(“customerid”).setAttribute(“defaulttype”, “2”);
Xrm.Page.getControl(“customerid”).setDefaultView(“a2d479c5-53e3-4c69-addd-802327e67a0d”);

This no longer works in CRM 2016 and I believe the source of the problem is explained here. Basically the new form rendering engine loads each script in separate iframes instead of the same frame as the form. This makes it so the document.getElementById() method can no longer find the element with the given name.

Finally I find out solution and it work for me.

I want to set “regarding” field in phone call to “contact” entity only.

var control = Xrm.Page.getControl(“regardingobjectid”);
control.getAttribute().setLookupTypes([“contact”]);

It works perfectly for me. Please try and post your comments if you face any issue.

Advertisements

About Asif
Hello Friends… I have done my Bachelor of Engineering in Information Technology from Gujarat University. I have 1.7 years experience of web and windows based application development.. My basic idea to start a blog is to store all important link which help me in my application and access to every where. Also this information is help others who want to makes their application powerful. I am interested in .net framework (1.0,2.0,3.0,3.5 and more). This blog contain also many information related to SQL, Custom Controls in C#.net Please share your ideas and any query if you have...

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: