Skip to content

Salesforce - SOQL Query

↩ Part of the Salesforce integration.

Runs a SOQL query (GET /query?q=...) and returns the records array directly in data.

This is the most flexible node of the family: filters, ordering, aggregations and parent-child relationships all live in the query itself. Use it to find records when you do not have their id, to build a report, or to feed a loop.

FieldTypeRequiredDescription
credentials_idcredentialsYesSalesforce credential
soqltextareaYesSOQL query, e.g. SELECT Id, Name FROM Account LIMIT 10

soql accepts dynamic variables, so {{data.email}} can be injected into the WHERE clause. This node has no sobject parameter — the object comes from the FROM clause of the query.

This module requires a Salesforce credential:

FieldDescription
login_urlhttps://login.salesforce.com or https://test.salesforce.com for a sandbox
client_id / client_secretConsumer Key and Secret of the Connected App
usernameSalesforce user
passwordPassword plus the security token, concatenated

data is the array of records (the records field of the Salesforce response), not the envelope:

[
{
"attributes": {
"type": "Account",
"url": "/services/data/v59.0/sobjects/Account/0015g00000AbCdEFGH"
},
"Id": "0015g00000AbCdEFGH",
"Name": "ACME S.A.",
"Industry": "Manufacturing"
},
{
"attributes": {
"type": "Account",
"url": "/services/data/v59.0/sobjects/Account/0015g00000IjKlMNOP"
},
"Id": "0015g00000IjKlMNOP",
"Name": "Globex",
"Industry": "Retail"
}
]

The counters travel in _meta:

{ "moduleVersion": "1.0.0", "success": true, "count": 2, "totalSize": 2, "done": true, "totalMs": 340 }
  • count — records returned in this call.
  • totalSize — records matching the query.
  • done — false when Salesforce split the result into several pages.

A query that matches nothing returns [] and count: 0 — not an error.

SELECT Id, FirstName, LastName, AccountId FROM Contact WHERE Email = '{{data.email}}' LIMIT 1
SELECT Id, Name, Amount, StageName, CloseDate
FROM Opportunity
WHERE CloseDate = THIS_MONTH AND StageName != 'Closed Lost'
ORDER BY Amount DESC
LIMIT 200

Accounts with their contacts (parent-child)

Section titled “Accounts with their contacts (parent-child)”
SELECT Id, Name, (SELECT Id, Email FROM Contacts) FROM Account WHERE Industry = 'Manufacturing' LIMIT 50
SELECT COUNT(Id) total FROM Lead WHERE CreatedDate = LAST_N_DAYS:7
  • The node returns only the first page. Salesforce pages long results (2.000 records by default) and sets done: false plus a nextRecordsUrl; this node does not follow it. Narrow the query with WHERE and LIMIT, or call the pagination endpoint with the HTTP node.
  • Text values in the query go between single quotes: WHERE Email = 'ana@acme.com'. A value containing a quote breaks the query — sanitise it before injecting it.
  • Every record carries an attributes block with its type and URL. Use a data mapping node to drop it before exporting.
  • Aggregate queries (COUNT, SUM, GROUP BY) return AggregateResult rows, where unaliased columns are named expr0, expr1… Alias them, as in the last example.
  • Date literals such as TODAY, THIS_MONTH or LAST_N_DAYS:7 go without quotes.
  • A malformed query returns 400 MALFORMED_QUERY with the position of the problem. It is not retried.