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
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 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp