We have a pretty complex lookup filter that we use to display "Associated Contacts" so the user doesn't have to enter a duplicate when one billing account has multiple service accounts. The problem is, during initial development, we had a requirement to associate the "Customer" that was attached to a lead, opportunity, quote, case, etc... to the "Service Account", or as we call it, "Site". This is because the Lead starts out at the Site address for us, then we associate it to a related Customer if that customer already is in our system.
We use connection roles for this when there are multiple "Sites" for a "Customer". Think McDonalds Corporate for the Billing Account.. and various locations as the Sites.
So, when adding a related contact to an Opp or a Quote, the basic view will only relate the Contact to the "Site's" Contacts. We added a custom view via JavaScript that looked up all "Associated Contacts".
The problem is this fetchxml times out almost all the time before data can be displayed in the lookup grid.
Is there a better way to do this now? When using connection roles to display all related contacts to either the "Site" or the "Customer"?
var lookupFilter =
'<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >' +
'<entity name="contact" >' +
'<attribute name="contactid" />' +
'<attribute name="fullname" />' +
'<attribute name="emailaddress1" />' +
'<attribute name="telephone1" />' +
'<attribute name="parentcustomerid" />' +
'<link-entity name="account" from="accountid" to="parentcustomerid" link-type="outer" alias="ca" >' +
'<attribute name="accountnumber" />' +
'</link-entity>' +
'<link-entity name="new_contact_account" from="contactid" to="contactid" link-type="inner" alias="nton" >' +
'<link-entity name="connection" from="record2id" to="accountid" link-type="outer" alias="con" >' +
'<filter type="or" >' +
'<condition attribute="record2roleid" operator="in" >' +
'<value uiname="Site" uitype="connectionrole">CA731AB5-D143-E811-A834-000D3A37C8E1</value>' +
'<value uiname="Customer" uitype="connectionrole">E45A17A9-D143-E811-A834-000D3A37C8E1</value>' +
'</condition>' +
'<condition attribute="record1roleid" operator="in" >' +
'<value uiname="Site" uitype="connectionrole">CA731AB5-D143-E811-A834-000D3A37C8E1</value>' +
'<value uiname="Customer" uitype="connectionrole">E45A17A9-D143-E811-A834-000D3A37C8E1</value>' +
'</condition>' +
'</filter>' +
'</link-entity>' +
'<link-entity name="connection" from="record1id" to="accountid" link-type="outer" alias="con2" >' +
'<filter type="or" >' +
'<condition attribute="record2roleid" operator="in" >' +
'<value uiname="Site" uitype="connectionrole" >CA731AB5-D143-E811-A834-000D3A37C8E1</value>' +
'<value uiname="Customer" uitype="connectionrole" >E45A17A9-D143-E811-A834-000D3A37C8E1</value>' +
'</condition>' +
'<condition attribute="record1roleid" operator="in" >' +
'<value uiname="Site" uitype="connectionrole" >CA731AB5-D143-E811-A834-000D3A37C8E1</value>' +
'<value uiname="Customer" uitype="connectionrole" >E45A17A9-D143-E811-A834-000D3A37C8E1</value>' +
'</condition>' +
'</filter>' +
'</link-entity>' +
'</link-entity>' +
'<filter type="and" >' +
'<condition attribute="statecode" operator="eq" value="0" />' +
'<filter type="or" >' +
'<condition entityname="con" attribute="record1id" operator="eq" value="' + accountId + '" />' +
'<condition entityname="con" attribute="record2id" operator="eq" value="' + accountId + '" />' +
'<condition entityname="con2" attribute="record1id" operator="eq" value="' + accountId + '" />' +
'<condition entityname="con2" attribute="record2id" operator="eq" value="' + accountId + '" />' +
'<condition entityname="nton" attribute="accountid" operator="eq" value="' + accountId + '" />' +
'</filter>' +
'</filter>' +
'</entity>' +
'</fetch>';