Salesforce (Apps step)

Updated Nov 23, 2026
DataMagik Automate

Salesforce

Queries, reads, creates and updates Salesforce records (accounts, opportunities, cases, custom objects) through the REST API.

Use it to connect the plant to sales and service: list the week's won opportunities for production planning, raise a Case when a customer's shipment is late, or update an account with what shipped.

Beta. This step has not yet been checked against a live Salesforce account, so treat its first runs as a test, and tell us if an operation does not answer as described.

Find it in the workflow editor's palette under Apps. See Apps steps for what every Apps step has in common.

Set it up

  1. In Salesforce Setup, have your admin create an External Client App (or a Connected App) with OAuth enabled, the scopes api and refresh_token, and the Redirect URI DataMagik shows on the OAuth 2.0 credential as its callback URL; note its consumer key and secret.
  2. Add your My Domain host (such as acme.my.salesforce.com) to Allowed Domains in the workflow's Script settings.

Credential: An OAuth 2.0 credential for your Salesforce External Client App or Connected App, connected by a user who can see and change the records the workflow uses.

Signing in with OAuth 2.0

Grant typeSign in with the provider (authorization code). Save the credential, then click Connect on it.
Sign-in (authorization) URLhttps://login.salesforce.com/services/oauth2/authorize
Token URLhttps://login.salesforce.com/services/oauth2/token
Scopeapi refresh_token

Register the Redirect URI the credential form shows in the provider's app settings.

Create an External Client App or Connected App in Salesforce Setup with OAuth enabled, the scopes api and refresh_token, and the credential's Redirect URI as the callback URL; use its consumer key and secret as the client id and secret. For a sandbox, use https://test.salesforce.com/services/oauth2/authorize and https://test.salesforce.com/services/oauth2/token instead.

Hosts it calls: *.my.salesforce.com

Connection

FieldRequiredWhat to put
My DomainYesYour My Domain name, the part of your Salesforce address before .my.salesforce.com: acme for acme.my.salesforce.com, or acme--uat.sandbox for the sandbox acme--uat.sandbox.my.salesforce.com. For example acme.

Operations

OperationWhat it does
Record › Query (SOQL)Runs a SOQL query and returns the matching records, following every batch up to the step's page limit.
Record › GetReads one record by its Id.
Record › CreateCreates a record of an object.
Record › UpdateChanges fields on one record; fields you leave out keep their values.

Record › Query (SOQL)

Runs a SOQL query and returns the matching records, following every batch up to the step's page limit.

Calls GET /query. Follows the pages, up to Most pages (10 unless you change it).

FieldRequiredWhat to put
SOQLYesThe SOQL query: SELECT the fields you want FROM an object, with an optional WHERE, ORDER BY and LIMIT. For example SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won'.

What comes out: One item per record, with the fields the query selects, such as {{ $json.Id }} and {{ $json.Name }}, and {{ $json.attributes.type }} (the object). A related field comes nested: {{ $json.Account.Name }}.

Example: SELECT Id, CaseNumber, Subject FROM Case WHERE Status = 'New' AND Origin = 'Plant' lists new plant cases for the quality team's daily email.

Record › Get

Reads one record by its Id.

Calls GET /sobjects/{sobject}/{id}.

FieldRequiredWhat to put
ObjectYesThe object's API name, such as Account, Opportunity, Case or Quality_Hold__c. For example Account.
Record IdYesThe record's 15- or 18-character Salesforce Id. For example 0015g00000XyZabAAF.
Fields to returnNoComma-separated field API names; leave empty for every field. For example Name,Industry,BillingCity.

What comes out: One item: the record, with {{ $json.Id }}, {{ $json.attributes.type }} and its fields, such as {{ $json.Name }}.

Example: Read Account {{ $json.sf_account_id }} for its BillingCity and ShippingCity before printing a customer label.

Record › Create

Creates a record of an object.

Calls POST /sobjects/{sobject}.

FieldRequiredWhat to put
ObjectYesThe object's API name, such as Account, Opportunity, Case or Quality_Hold__c. For example Account.
Record fieldsYesA JSON object of field API names and values for the new record; every field the object requires must be in it. For example {"Subject": "Late shipment {{ $json.shipper }}", "AccountId": "{{ $json.sf_account_id }}", "Origin": "Plant"}.

What comes out: One item: {{ $json.id }} (the new record's Id), {{ $json.success }} (true) and {{ $json.errors }} (an empty list).

Example: When a shipper is late, create a Case with the customer's AccountId and the shipper number in the Subject, then save {{ $json.id }} with the shipper.

Record › Update

Changes fields on one record; fields you leave out keep their values.

Calls PATCH /sobjects/{sobject}/{id}.

FieldRequiredWhat to put
ObjectYesThe object's API name, such as Account, Opportunity, Case or Quality_Hold__c. For example Account.
Record IdYesThe record's 15- or 18-character Salesforce Id. For example 0015g00000XyZabAAF.
Record fieldsYesA JSON object of the field API names to change and their new values; only these fields change. For example {"Status": "Closed"}.

What comes out: Salesforce answers an update with 204 and no content, so the step puts out one item with {{ $json.status }} 204 and an empty {{ $json.body }} when it worked.

Example: When the late shipper is confirmed, update Case {{ $json.sf_case_id }} with {"Status": "Closed"}.

Trigger: Salesforce: New Items

Under Triggers in the palette. It looks at Salesforce on a schedule (every 15 minutes unless you change Look every) with one of these operations: Record › Query (SOQL), and starts the workflow with the items it has not seen on an earlier look, one item each. Saving the workflow sets up the schedule.

  • New means: not seen before, by the item's id (or the field you name in Item field), or newer than the newest one last time, by a date or increasing number.
  • On the first run it only remembers what is there, unless you choose Start with everything.
  • Test runs show what would be new without remembering it. It remembers the last 5000 ids, so filter the list to keep it shorter than that.

Example

A schedule runs Salesforce › Query with SELECT Id, Name, CloseDate, Amount FROM Opportunity WHERE StageName = 'Closed Won' AND CloseDate = THIS_WEEK, and a Document step turns the items into a planning sheet.

Tips

  • Object is the API name, not the label: Account, Opportunity, Case, and custom objects end in __c (Quality_Hold__c). Custom fields end in __c too.
  • SOQL has no SELECT *: name every field you want. Text values go in single quotes, dates do not (CloseDate > 2026-01-31).
  • Salesforce counts every call against your org's daily API limit; a query that pages through many records uses one call per 2,000 records.
  • It calls Salesforce on test runs too, so create and update records in a sandbox while building.

Settings every Apps step has

  • More query parameters: any query parameter the fields do not offer, sent as is.
  • More body fields: a JSON object merged into the request body; nested objects merge, other values replace.
  • Most requests per second: spaces the calls out for rate limits. A "too many requests" (429) answer is retried after the wait the API asks for.
  • Most pages: for operations that follow pages, the most pages to fetch (10 unless you change it, up to 100). The run warns when it stops with more to get.
  • Fail on a non-2xx response: on by default. Turn it off to handle errors yourself.

Salesforce's own API documentation: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm

Was this page helpful?