File: query.nu 4 exported commands 0 internal commands

sf query

Run a SOQL query against Salesforce.

Returns the records as a table by default, with Salesforce attributes metadata removed. Use --include-attributes to keep the attributes fields in each returned record. Use --raw to get the full Salesforce response (includes totalSize, done, etc). Use --all to auto-paginate through all result pages. Use --include-deleted to query deleted/archived records (uses queryAll/ endpoint).

Usage

sf query {flags} <soql>

Flags

-h, --help
Display the help message for this command
--all
Auto-paginate to fetch all records
--raw
Return the raw Salesforce JSON response
--include-attributes
Keep Salesforce attributes metadata in each returned record
--include-deleted
Include deleted/archived records (queryAll endpoint)

Parameters

soql <string>
The SOQL query string

Input/output types

#inputoutput
0anyany

Examples

query accounts

sf query "SELECT Id, Name FROM Account LIMIT 10"

query all leads with auto-pagination

sf query --all "SELECT Id, Name FROM Lead"

keep Salesforce attributes metadata

sf query --include-attributes "SELECT Id, Product2.Name FROM Asset LIMIT 1"

get raw query response

sf query --raw "SELECT Id FROM Contact"

query deleted records

sf query "SELECT Id FROM Account WHERE IsDeleted = true" --include-deleted

sf query-more

Fetch the next page of results from a previous query.

Use this when you get partial results and want manual pagination control. Returned records omit Salesforce attributes metadata by default. Pass the nextRecordsUrl from a --raw query response.

Usage

sf query-more {flags} <next_records_url>

Flags

-h, --help
Display the help message for this command
--raw
Return the raw Salesforce JSON response
--include-attributes
Keep Salesforce attributes metadata in each returned record

Parameters

next_records_url <string>
The nextRecordsUrl from a previous query response

Input/output types

#inputoutput
0anyany

Examples

fetch the next page of query results

let page1 = (sf query --raw "SELECT Id FROM Account"); if (not $page1.done) { sf query-more $page1.nextRecordsUrl }