Hi All,
I tried to setup "Account" entity as default for Connect To lookup and also to filter records using addCustomView but it's not working. It shows Contact lookup view as default. Please find below the JS:
var viewId = Xrm.Page.getControl("record2id").getDefaultView();
var entityName = "account";
var viewDisplayName = "Accounts connected to";
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+
"<entity name='account'>"+
" <attribute name='name' />"+
"<attribute name='accountid' />"+
"<order attribute='name' descending='false' />"+
"<filter type='or'>"+
" <condition attribute='tenanttype' operator='eq' value='1' />"+
" <condition attribute='tenanttype' operator='eq' value='2' />"+
"</filter>"+
"</entity>"+
"</fetch>";
var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>"+
"<row name='result' id='accountid'>"+
"<cell name='name' width='300' />"+
"</row>"+
"</grid>";
document.getElementById("record2id").setAttribute("defaulttype","1");
document.getElementById("record2id").setAttribute("lookuptypes","1");
Xrm.Page.getControl("record2id").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
// Xrm.Page.getControl("record2id").setDefaultView(viewId);
document.getElementById("record2id").disableViewPicker = 1;
Please let me know about solution, if any.
Thank you.
JayshriP