salesforce_query_records
Query records from any Salesforce object using SOQL, with support for parent-to-child and child-to-parent relationship queries. Paginate through results with limit and offset.
Instructions
Query records from any Salesforce object using SOQL, including relationship queries.
NOTE: For queries with GROUP BY, aggregate functions (COUNT, SUM, AVG, etc.), or HAVING clauses, use salesforce_aggregate_query instead.
Pagination: Results default to 200 records per page. Use limit and offset to page through results. Response includes total record count and next offset. Note: Pages are not snapshot-consistent — if data changes between requests, records may shift. For stable pagination, add a deterministic WHERE clause (e.g., WHERE CreatedDate < 2026-04-07T00:00:00Z ORDER BY Id).
Examples:
Parent-to-child query (e.g., Account with Contacts):
objectName: "Account"
fields: ["Name", "(SELECT Id, FirstName, LastName FROM Contacts)"]
Child-to-parent query (e.g., Contact with Account details):
objectName: "Contact"
fields: ["FirstName", "LastName", "Account.Name", "Account.Industry"]
Multiple level query (e.g., Contact -> Account -> Owner):
objectName: "Contact"
fields: ["Name", "Account.Name", "Account.Owner.Name"]
Related object filtering:
objectName: "Contact"
fields: ["Name", "Account.Name"]
whereClause: "Account.Industry = 'Technology'"
Paginate through results:
objectName: "Account"
fields: ["Name"]
limit: 50
offset: 100
Note: When using relationship fields:
Use dot notation for parent relationships (e.g., "Account.Name")
Use subqueries in parentheses for child relationships (e.g., "(SELECT Id FROM Contacts)")
Custom relationship fields end in "__r" (e.g., "CustomObject__r.Name")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectName | Yes | API name of the object to query | |
| fields | Yes | List of fields to retrieve, including relationship fields | |
| whereClause | No | WHERE clause, can include conditions on related objects | |
| orderBy | No | ORDER BY clause, can include fields from related objects | |
| limit | No | Maximum number of records to return (default 200) | |
| offset | No | Number of records to skip for pagination (default 0, max 2000) |