fetchxml question RRS feed

  • Question

  • for example, Entity A, B, C, A is B's parent, B is C's parent, And I want to query how many C's for each A?

    Is there a way to fetchXML on these three entities?
    Thank you.

    Monday, December 22, 2008 5:23 PM


  • Essentially you want to know how many grandchildren there are for A.

    You will need to retrieve all values and then count the resulting entities:

    The following example retrieves all activites for all contacts that belong to a particular account. Note I had to use the 'link' node to link my contact to activity and account to contact.

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
    <attribute name="activityid"/>
    <link-entity name="contact" from="contactid" to="regardingobjectid" alias="ab">
    <link-entity name="account" from="accountid" to="parentcustomerid" alias="ad">
    <filter type="and">
    <condition attribute="accountid" operator="eq" uiname="FF" uitype="account" value="{AE711D03-E2BE-41B0-9D4D-C0C798C05FD5}"/>

    An easy way to generate the fetchXML is to perform your advance find query to retrieve the correct list of 'grandchildren' (entity C) and then click F11 then copy the following line into the top nav box:

    javascriptStick out tonguerompt('my%20query:',%20resultRender.FetchXml.value);

    Copy and paste in JS/C#


    Tuesday, December 23, 2008 9:26 AM