Asked by:
Set Default Lookup Type for Customer Lookup in MS CRM 2013

Question
-
Hi,
I know there is a workaround for setting a lookup type as Contact for CRM 2011. However this doesn't work for CRM 2013.
Has anyone succeeded in finding a workaround for this scenario in CRM 2013. I need to set up default lookup type as Contact in Customer lookup and also similar requirement to set default lookup type as Contact for Email 'to' field
Thanks in Advance,
Ravi
Thursday, May 8, 2014 6:23 AM
All replies
-
Thursday, May 8, 2014 7:53 AM
-
This code will help you do this for the customerid field. (Only in CRM 2013)
setTimeout(function() {
var imgButton = $('#customerid_i'); imgButton.attr('defaulttype', '2'); //changes default advanced find entity type to contact imgButton.attr('lookuptypes', '2,1'); //changes recent items to contacts
}, 1000);
The same can be done for any lookup field simply by appending _i to its field name.
The reason for the setTimeout is that the customerid_i element is an img element that's added dynamically to the DOM. So it might not be in the DOM on the Form onLoad.
Regards,
Tuesday, May 13, 2014 7:31 AM -
- Edited by HIMBAPModerator Thursday, May 15, 2014 1:00 AM
- Proposed as answer by HIMBAPModerator Thursday, May 15, 2014 1:07 AM
Thursday, May 15, 2014 12:59 AMModerator -
Hello,
I came across with the same issue in CRM 2016.
1) I would like to set the the default search entity as Contacts.
2) I dont want to apply any filter as users can select contacts or accounts in the customer field.
I took the FetchXML and LayoutXML of my preferred view for Contact e.g., "My Active Contacts" and bound it using addCustomView
var viewId = null, entityName = null, viewDisplayName = null, fetchXml = null, layoutXml = null, isDefault = null, fetchXml2 = null; viewId = "A2D479C5-53E3-4C69-ADDD-802327E67A0D"; entityName = "contact"; viewDisplayName = "My Active Contacts"; fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='contact'><attribute name='fullname'/><attribute name='parentcustomerid'/><attribute name='telephone1'/><attribute name='emailaddress1'/><attribute name='contactid'/><attribute name='fax'/><attribute name='address1_name'/><attribute name='address1_fax'/><attribute name='ssc_kundmyndighetorganisationid'/><order attribute='fullname' descending='false'/><filter type='and'><condition attribute='statecode' operator='eq' value='0'/></filter></entity></fetch>"; // Grid layout specification layoutXml = "<grid name='resultset' object='2' jump='fullname' select='1' preview='0' icon='1'><row name='result' id='contactid'><cell name='fullname' width='300' /><cell name='ssc_kundmyndighetorganisationid' width='200' /><cell name='emailaddress1' width='200' /><cell name='parentcustomerid' width='150' /><cell name='telephone1' width='125' /><cell name='fax' ishidden='1' width='100' /><cell name='address1_name' ishidden='1' width='100' /><cell name='address1_fax' ishidden='1' width='100' /></row></grid>"; isDefault = true; Xrm.Page.getControl("customerid").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault);
Software Engineer
Friday, May 27, 2016 9:51 AM