Query Salesforce aggregate SOQL with GROUP BY ROLLUP and a HAVING clause to produce hierarchical sales summaries, then parse multi-level grouping metadata from the API response
domain: salesforce.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to salesforce.com, checked against official docs, with linked verified routes.
Steps
Construct a SOQL query using GROUP BY ROLLUP(field1, field2) with aggregate functions (SUM, COUNT) and a HAVING clause filtering on an aggregate result
Execute via GET /services/data/vXX.0/query?q={encodedSOQL} or the Tooling API query endpoint
Inspect the 'records' array in the JSON response — rows where a grouping field is null indicate a rollup subtotal or grand total row
Check the 'attributes.type' and use the grouped field nullness pattern to reconstruct the subtotal hierarchy in your application code
Handle pagination via 'nextRecordsUrl' if the aggregate result set exceeds the batch size
Known gotchas
ROLLUP produces null values in grouping fields for subtotal rows — these nulls are valid rollup indicators, not missing data, and must be handled differently from ordinary null field values
HAVING clauses in Salesforce SOQL only accept aggregate function references, not aliases; repeating the full expression is required
GROUP BY ROLLUP is not supported in Bulk API query jobs; use the synchronous query REST endpoint only
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?