Portal Community

soql/execute

Execute a custom SOQL (Salesforce Object Query Language) query and retrieve the first page of results.

SOQL Injection Warning: Never interpolate raw user input directly into a SOQL query string. This creates SOQL injection vulnerabilities. Always sanitize dynamic values, use static query patterns, or validate input before constructing the query.

When to Use

Configuration

Connection

FieldTypeRequiredDescription
InstanceUrlstringrequiredSalesforce org URL.
AccessTokenstringrequiredValid OAuth2 access token.

Operation Fields

FieldTypeRequiredDescription
QuerystringrequiredA valid SOQL query string, e.g. SELECT Id, Name, Email FROM Contact WHERE CreatedDate = LAST_30_DAYS LIMIT 100.

Sample Configuration

{
  "Resource": "soql",
  "Operation": "execute",
  "InstanceUrl": "https://myorg.my.salesforce.com",
  "AccessToken": "{{credentials.salesforce.accessToken}}",
  "Query": "SELECT Id, Name, Email FROM Contact WHERE CreatedDate = LAST_30_DAYS LIMIT 100"
}

Validation Errors

Error CodeCondition
CFG_MISSING_INSTANCEInstanceUrl is missing.
CFG_MISSING_TOKENAccessToken is missing.
VAL_MISSING_FIELDQuery is missing or empty.
UNEXPECTED_ERRORUnexpected exception or SOQL syntax error.

Output

Success Port

FieldTypeDescription
recordsarrayArray of result objects. Each object contains the fields specified in your SELECT clause.
totalSizeintTotal number of records matching the query in this response page.
donebooltrue if all results are included. false if more pages exist — use soql/executeWithPagination instead.
resourcestringAlways soql.
operationstringAlways execute.

Error Port

FieldTypeDescription
errorCodestringMachine-readable error code.
messagestringError description including SOQL error details.

Sample Output

{
  "records": [
    { "Id": "0035g000006LmnOPQ", "Name": "Alex Rivera", "Email": "alex@acme.com" },
    { "Id": "0035g000006XyzABC", "Name": "Sam Torres", "Email": "sam@beta.com" }
  ],
  "totalSize": 2,
  "done": true,
  "resource": "soql",
  "operation": "execute"
}

Expression Reference

ExpressionDescription
{{nodes.SOQLQuery.records}}Array of query results.
{{nodes.SOQLQuery.totalSize}}Number of records returned in this page.
{{nodes.SOQLQuery.done}}Whether all pages are included.
{{nodes.SOQLQuery.records[0].Id}}First result's Salesforce ID.

Node Policies & GuardRails

PolicyDetail
SOQL injection preventionNever interpolate unsanitized user input into the Query field. Always construct queries from static templates with validated dynamic values.
Pagination checkIf done is false, the result is paginated. Use soql/executeWithPagination to retrieve all records automatically.
LIMIT clauseAlways include a LIMIT clause in queries unless you specifically need all records. Without a LIMIT, large orgs may return very large result sets.
Credential storageStore AccessToken in BizFirst Credentials Manager.
Error port wiringAlways wire the error port. Invalid SOQL syntax routes to the error port with details.

Examples

Aggregate Count Query

{
  "Query": "SELECT COUNT(Id) totalLeads, Status FROM Lead WHERE CreatedDate = THIS_MONTH GROUP BY Status"
}
// records[0].totalLeads, records[0].Status

Multi-Object Relationship Query

{
  "Query": "SELECT Id, Name, (SELECT Id, LastName FROM Contacts) FROM Account WHERE Type = 'Customer' LIMIT 50"
}

Incremental Sync — Recently Modified

{
  "Query": "SELECT Id, Name, Email, LastModifiedDate FROM Contact WHERE LastModifiedDate > {{variables.lastSyncTimestamp}} LIMIT 500"
}