Salesforce query tutorial
Learn how to read and write data to Salesforce.
After setting up a Salesforce integration with Retool, your Salesforce resource is available to use in the query editor. You can then configure a query using the Salesforce Object Query Language (SOQL) or other query types to retrieve and modify data from Salesforce.
Query types
Under Query types, choose the method to use to query Salesforce. SOQL queries are often used to read data, and CRUD action and Bulk load are often used to write data.
SOQL queries
Select SOQL query to construct queries using Salesforce Object Query Language (SOQL) syntax.
For example, the following query retrieves opportunities marked "Closed Won" within the last month.
SELECT Id, Name
FROM Opportunity
WHERE StageName = 'Closed Won' and CloseDate >= {{ moment().format('YYYY-MM-01') }}
CRUD action
The CRUD Action query type supports Retrieve, Create, Update, Delete, and Upsert operations. It accepts a Resource type and Resource ID. See the Salesforce Object Reference for a list of standard objects.
Bulk load
Using the Bulk load query type, Retool supports Bulk Insert, Bulk Update, Bulk Upsert, and Bulk Delete operations.
For example, the following query inserts Account objects.
The following query updates Account objects. The extIdField
option specifies the external ID field name.
Troubleshoot access tokens
If you see an expired access/refresh token
error when running Salesforce queries, you may need to change a setting in Salesforce to allow Retool to generate valid access and refresh tokens.
- If you have Enforce IP restrictions set in your IP Relaxation settings, consider editing your policy to Refresh token is valid until revoked.
- Ensure you only enable the Connect to a sandbox organization resource setting if you are connecting to a developer sandbox organization.
- Ensure the Timeout value in your organization-wide settings is not too low.