locked
In MS CRM 2011, How to get top 5 records in SSRS Reports using Fetch XML. RRS feed

  • Question

  • How to fetch only top 5 related records from "new_switch" entity from the below mention Fetch XML Query using link-entity?

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="new_equipment">

          <attribute name="new_name" />

        <filter type="and">
          <condition attribute="new_equipmentid" operator="eq" value="@EquipmentId" />
        </filter>
        <link-entity name="new_switch" from="new_equipmentname" to="new_equipmentid" alias="aa">

            <attribute name="new_manufacturer" />
            <attribute name="new_modelno" />
            <attribute name="new_serialno" />

        </link-entity>
      </entity>
    </fetch>

    NOTE :

    i'm able to fetch top 5 records as mention below, but not using link-entity.please help..

               

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="5">
      <entity name="new_equipment">

          <attribute name="new_name" />

      </entity>
    </fetch>

                           
    • Edited by Crm.Abhi Friday, February 17, 2012 11:02 AM
    Friday, February 17, 2012 10:34 AM

Answers

  • Hi,

    You need to invert your query and search for new_switch and link to new_equipment. You will then apply your filter to the link entity. I suggest you use Advanced fine to create the query starting from new_switch and then download the fetchxml and add the count="5".

    hth,

    Scott


    www.develop1.net
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Marked as answer by Crm.Abhi Friday, February 17, 2012 3:28 PM
    Friday, February 17, 2012 11:30 AM
    Answerer

All replies

  • Hi,

    You need to invert your query and search for new_switch and link to new_equipment. You will then apply your filter to the link entity. I suggest you use Advanced fine to create the query starting from new_switch and then download the fetchxml and add the count="5".

    hth,

    Scott


    www.develop1.net
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Marked as answer by Crm.Abhi Friday, February 17, 2012 3:28 PM
    Friday, February 17, 2012 11:30 AM
    Answerer
  •   Thanks a lot Scott.

      Abhi


    Abhi.Srmk

    Friday, February 17, 2012 3:30 PM