Answered by:
FetchXML - Can you Link one link entity to another link entity?

Question
-
I am just getting started using FetchXML to develop SSRS reports for CRM Online 2011. I am trying to determine if it is possible to link link entities to other link entities as opposed to the main entity. For example, I have quotes in the system tied to contacts. Contacts are tied to Accounts. Would it be possible to use quotes as the main entity, have a link entity for contacts, and then link the contacts to the account entity? Or, do all of the link entities have to be linked to the main entity?This would be the equivalent in SQL (using entity names as opposed to table names for the sake of this example):
SELECT * FROM Quotes INNER JOIN Contacts ON Quotes.ContactID = Contacts.ContactID INNER JOIN Accounts ON Contacts.ParentCustomerID = Accounts.AccountID
ORselect * from a INNER JOIN b on a.key = b.key INNER JOIN c on b.key2 = c.key2
I have been able to come up with a couple of workarounds, such as putting the account ID on the quote in addition to the contact. Also, I have tried using a parameter and a second dataset in the report (which worked), but I would really like to know if it is possible to develop queries like the ones above using FetchXML or if I will have to rely on workarounds. In other words, I am less interested in coming up with a specific solution to this problem and more interested in knowing if FetchXML limits you to only establishing links to the main entity in a query.
Tuesday, August 16, 2011 3:21 PM
Answers
-
You can do this with fetchXml. Try something like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="quote">
<attribute name="quotenumber" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="contactid" to="customerid" alias="aa">
<attribute name="lastname" />
<link-entity name="account" from="accountid" to="parentcustomerid" alias="ab">
<attribute name="name" />
</link-entity>
</link-entity>
</entity>
</fetch>
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Proposed as answer by Daniel Cai - KingswaySoftMVP Tuesday, August 16, 2011 5:27 PM
- Marked as answer by jcapallo Tuesday, August 16, 2011 5:41 PM
Tuesday, August 16, 2011 5:23 PMModerator
All replies
-
You can do this with fetchXml. Try something like this:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="quote">
<attribute name="quotenumber" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="contactid" to="customerid" alias="aa">
<attribute name="lastname" />
<link-entity name="account" from="accountid" to="parentcustomerid" alias="ab">
<attribute name="name" />
</link-entity>
</link-entity>
</entity>
</fetch>
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Proposed as answer by Daniel Cai - KingswaySoftMVP Tuesday, August 16, 2011 5:27 PM
- Marked as answer by jcapallo Tuesday, August 16, 2011 5:41 PM
Tuesday, August 16, 2011 5:23 PMModerator -
That worked perfectly! Thanks so much!
I had tried the same thing yesterday but I think I must have had my to and from links mixed up.
Tuesday, August 16, 2011 5:41 PM