locked
FetchXML Opportunity Query RRS feed

  • Question

  • hi,

    i need a fetchxml query to get won opportunity value sum of each sales agent in the quarter period, my currect query:>

    <fetch distinct="false" mapping="logical" aggregate="true" >
        <entity name="opportunity" >
            <attribute name="actualvalue" alias="opportunity_sum" aggregate="sum" />
            <attribute name="createdbyname" alias="Commercial" groupby="true"/>
            <attribute name="actualclosedate" groupby="true" dategrouping="quarter" alias="Trimestre" />
            <filter type="and" >
                <condition attribute="statecode" operator="eq" value="Won" />
            </filter>
        </entity>
    </fetch>

    i need to know if correct or no, any helper.


    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]



    • Edited by Ammar.Zaied Thursday, April 2, 2015 10:28 AM
    Thursday, April 2, 2015 10:23 AM

Answers

  • Hello,

    Looks like almost correct. One thing I would suggest to change is value for condition like:


    <fetch distinct="false" mapping="logical" aggregate="true" >
        <entity name="opportunity" >
            <attribute name="actualvalue" alias="opportunity_sum" aggregate="sum" />
            <attribute name="createdbyname" alias="Commercial" groupby="true"/>
            <attribute name="actualclosedate" groupby="true" dategrouping="quarter" alias="Trimestre" />
            <filter type="and" >
                <condition attribute="statecode" operator="eq" value="1" />
            </filter>
        </entity>
    </fetch>


    To check your query against CRM I would suggest to use XrmToolbox tool. Also you can use one of plugins to build your query.


    Dynamics CRM MVP
    My blog

    • Marked as answer by Ammar.Zaied Thursday, April 2, 2015 10:50 AM
    Thursday, April 2, 2015 10:44 AM
    Moderator

All replies

  • Hello,

    Looks like almost correct. One thing I would suggest to change is value for condition like:


    <fetch distinct="false" mapping="logical" aggregate="true" >
        <entity name="opportunity" >
            <attribute name="actualvalue" alias="opportunity_sum" aggregate="sum" />
            <attribute name="createdbyname" alias="Commercial" groupby="true"/>
            <attribute name="actualclosedate" groupby="true" dategrouping="quarter" alias="Trimestre" />
            <filter type="and" >
                <condition attribute="statecode" operator="eq" value="1" />
            </filter>
        </entity>
    </fetch>


    To check your query against CRM I would suggest to use XrmToolbox tool. Also you can use one of plugins to build your query.


    Dynamics CRM MVP
    My blog

    • Marked as answer by Ammar.Zaied Thursday, April 2, 2015 10:50 AM
    Thursday, April 2, 2015 10:44 AM
    Moderator
  • thanks Andrii.

    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

    Thursday, April 2, 2015 10:50 AM