locked
issue with Fetch XML Distinct for a column RRS feed

  • Question

  • Dear CRM Specialists,

    I have a query. I need to find the distinct records by its condition. I have used following query. But it gives all records not by distinct. Where as when I fired same query in the Fetch XML tool , It gives me distinct record. Could you Please help me on this.

    "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' >"
        "<entity name='contact' >"
            "<attribute name='firstname' distinct='true' />"
            "<filter type='and' >"
                "<condition attribute='firstname' operator='eq' value='vivek' />"
            "</filter>"
        "</entity>"
    "</fetch>"

    Above Query does not give distinct results in the code whereas It gives distinct records when I Fired same query in Fetch XML Tool like Xrmtoolbox and crm2011FetchXmlExecuteTool.

    Thanks & Regards,
    Vivek Gupta

    Vivek gupta

    Wednesday, May 27, 2015 4:14 AM

All replies

  • Hi Vivek,

    Try with below query..

    "<fetch version='1.0' output-format='xml-platform' mapping='logical' aggregate='true' >"
         "<entity name='contact' >"
             "<attribute name='firstname' aggregate='countcolumn' alias='countName' distinct='true' />"
             "<filter type='and' >"
                 "<condition attribute='firstname' operator='eq' value='vivek' />"
             "</filter>"
         "</entity>"
     "</fetch>"

    Wednesday, May 27, 2015 5:47 AM