Hi All,
I am trying to load a project entity lookup field(custom entity) in the opportunity entity. I want this lookup to not to load all those project which are already assigned to other opps for same customer.
I have already search for the solution and found the solution sating it can be achieved using addCustomeview function and tried it with below mention code but getting invalid argument error not sure why.
function getFilteredLookup() {
debugger;
var customerid= Xrm.Page.getAttribute("parentcontactid").getValue();
var viewId = Xrm.Page.getControl("new_transferred_project").getDefaultView();
var entityName = "new_master_project";
if (customerid != null) {
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>";
fetchXml += "<entity name='new_master_project'>";
fetchXml += "<link-entity name='opportunity' from='new_transferred_project' to='new_master_projectid' alias='aa'>";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='parentcontactid' operator='ne' value='" + customerid+ "' />";
fetchXml += "</filter></link-entity></entity></fetch>";
var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>";
layoutXml+= "<row name='result' id='pfc_project_id'>";
layoutXml += "<cell name='name' width='150'/>";
layoutXml += "<cell name='new_project_id' width='150' /> </row></grid>";
var viewDisplayName="Filtered lookup view";
Xrm.Page.getControl("new_transferred_project").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
Let me know if you guys have solution for this problem i am facing.
Thanks in advance.







