Perform a Dynamics 365 Dataverse FetchXML aggregate query with groupby and linked-entity conditions, submitted via the Web API fetchXml query string parameter

domain: dynamics.microsoft.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Construct a FetchXML document with aggregate='true' on the fetch element, attribute elements with aggregate functions (sum, count, max) and alias attributes, and a 'groupby' attribute on the grouping field
  2. Add a link-entity element to join to a related table (e.g. linking opportunity to account) with link-type='inner' and a condition element on the linked entity's attribute
  3. URL-encode the FetchXML string and append it as the fetchXml query parameter to a GET request: /api/data/vX.X/opportunities?fetchXml={encodedXML}
  4. Set the Prefer: odata.include-annotations='OData.Community.Display.V1.FormattedValue' header to receive formatted values alongside raw values in the response
  5. Parse the '@Microsoft.Dynamics.CRM.fetchxmlpagingcookie' annotation from the response to retrieve additional pages using paging cookies

Known gotchas

Related routes

Use the Dynamics 365 Dataverse FetchXML API via the Web API to run aggregate and linked-entity queries
learn.microsoft.com/dynamics365 · 6 steps · unrated
Query Dataverse records using FetchXML submitted via the Web API
learn.microsoft.com · 6 steps · unrated
Query Dynamics 365 records using the Web API with OData filter expressions
learn.microsoft.com · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans