Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Custom Contact Subgrid FetchXML Query Timing Out - Using Connection Roles

(0) ShareShare
ReportReport
Posted on by

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>';

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans