# Salesforce bulk operations
The Salesforce connector supports bulk data operations, allowing you to load large datasets into Salesforce efficiently. Workato uses both bulk API v1.0 and bulk API v2.0 (opens new window) to support loading data from CSV files into Salesforce. The following operations are supported:
- Create objects in bulk from CSV file
- Update objects in bulk from CSV file
- Upsert objects in bulk from CSV file
- Retry bulk job for failed records from CSV file
- Search records in bulk using SOQL query
# Handle large files and scale effectively
Workato’s Salesforce connector enables you to manage large datasets and scale efficiently. When a CSV file exceeds 1 GB, Salesforce splits the file into 1 GB chunks. Workato stitches these chunks into a single stream for processing in your recipe, ensuring continuous data flow without requiring additional configuration.
You can use a single recipe to process datasets of varying sizes, such as 1 GB, 5 GB, or 10 GB, without any modifications. Workato provides pre-configured error handling, retries, and notifications, enabling you to manage bulk operations at any scale.
Scalability is built-in, allowing you to maintain consistent processing and reliable error handling as your datasets grow.
USE BULK API V2.0
For optimal performance, we recommend using the bulk API v2.0. This version reduces the impact on Salesforce API limits by batching records more efficiently.
All Salesforce bulk operations are asynchronous. When a bulk job is sent to Salesforce, Workato polls for results every five minutes. To maintain polling, you must start the recipes rather than test them.
For synchronous operations, refer to the Salesforce connector batch operations documentation, which supports creating, updating, and upserting objects in batches, with a maximum batch size of 2,000.
# Permissions
The following Salesforce user permissions are required for bulk operations to work correctly:
Manage Data Integrations
View Setup and Configuration
API Enabled
System administrator privileges are required to enable these permissions for the connected Salesforce account. For more details, refer to the Salesforce documentation (opens new window).
# Create/update/upsert objects in bulk via CSV file
There are 4 main sections/components in these bulk actions.
Salesforce bulk create via CSV file action sections
Action section | Description |
---|---|
CSV file input | Define the schema of the CSV files containing Salesforce bulk load data. |
Salesforce object to create/update/upsert | Define the Salesforce object to write to. Includes Primary key (usually external ID) for upsert operations. |
Relationship fields | Describe how the CSV data columns should map into Salesforce object fields. Note that relationship fields need to be utilized to support polymorphic columns. More details on polymorphic fields can be found here (opens new window) |
Advanced configuration | Define the size per Salesforce bulk job. Define whether this action should be synchronous or asynchronous. |
Let's go into each section in detail.
# CSV file input
In this section, define the schema of the CSV files containing Salesforce bulk load data. This enables Workato to read and extract data from your CSV files and move it into Salesforce accurately.
Input field | Description |
---|---|
File content | Provide the CSV file content here. This would typically be a datapill from a Download file action or from a New file trigger. |
Column separator | Describe the delimiter of your file - this can be comma, tab, colon, pipe, or space. |
Contains header line? | Describe whether the CSV file content you're providing contains a header line or not. This will tell Workato whether to skip the first line for processing, because we don't want to inaccurately process header lines as data. |
Columns names | Describe the names of the data columns in your CSV file. This will be used to generate the available CSV data for mapping into Salesforce in the CSV to Salesforce field mapping section. |
This is how the section should look after configuration.
Salesforce bulk action - configured CSV file input section
In our example, we used the sample CSV file below.
external_id,last_name,value
"a0K1h000003fXSS","Minnes","54"
"a0K1h000003fehx","Lecompte","12"
"a0K1h000003fjnv","Fester","28"
# Salesforce object to create/update/upsert
For the create and update operations, select the Salesforce object you wish to write to.
Salesforce bulk create action - configured Salesforce object section
For the upsert operations, select the Salesforce object you wish to write to as well as the Primary key of the object. A primary key in Salesforce is a unique identifier for each record. In order to carry out the bulk upsert action, your Salesforce object should have an External ID
field.
The External ID
field is a custom field that has the “External ID” attribute. It contains unique record identifiers from a system outside of Salesforce. External ID fields must be Custom text, number, or email fields.
Salesforce bulk upsert action - configured Salesforce object section
The bulk API for upsert also allows the use of other fields such as the internal Record ID in bulk upsert operations. Please note that these must be indexed fields. To use an indexed field, toggle the 'Primary key' to accept text input and type in the API name of the field.
The behavior while using an external ID and other indexed fields differ as follows:
Input value | External ID | Indexed fields |
---|---|---|
Match found | Updates record | Updates record |
No match found | Creates record | MALFORMED_ID:Id in upsert is not valid error |
No value | MISSING_ARGUMENT:External_ID__c not specified error | Creates records |
# Relationship fields mapping
Many objects in Salesforce are related to other objects. For example, Account is a parent of Contact. You can add a reference to a related object in a CSV file by representing the relationship.
Relationship fields are also utilized to allow polymorphic column mapping. Workato cannot infer the mapping automatically and these need to be manually specified.
Some objects also have relationships to themselves. For example, the Reports To field for a contact is a reference to another contact.
When unconfigured, this section will not map any data into Salesforce.
For each field that you wish to write to in Salesforce, select which column of the CSV file the data should come from. This action does not allow datapills or data transformation via formula mode as it streams the CSV file data into Salesforce.
Salesforce bulk upsert action - field mapping section
Learn more about relationship fields in a CSV header (opens new window).
# Advanced configuration
In this section, define whether the action should be synchronous or asynchronous. If synchronous, Workato waits for Salesforce to complete the bulk job processing before moving to the next recipe action. If asynchronous, Workato simply uploads the CSV file content into Salesforce and move to the next recipe action without waiting for Salesforce to complete the bulk job processing.
You can also define the size of the CSV file chunk per Salesforce bulk job. This defaults to 10 MB.
# Understanding the output datatree
The bulk operation's output datatree contains the following.
Salesforce bulk operation output datatree
Output datapill | Description | |
---|---|---|
All records successfully processed? | True if all CSV rows across Salesforce bulk jobs are processed successfully. False if any CSV rows across Salesforce bulk jobs failed. | |
Number of records failed | Total number of CSV rows that failed to be successfully processed in Salesforce. | |
Number of retried records | Total number of CSV rows that were retried to be processed in Salesforce. Only relevant for the retry action. | |
Number of records processed | Total number of CSV rows that were processed in total by Salesforce (failed + succeeded). | |
CSV content with failed records | CSV file content containing CSV rows in the original API request which failed to be successfully processed. 2 additional columns are added to this CSV file - **sf__Error** and **sf__Id**. Refer to the Salesforce documentation for more information. | |
Salesforce bulk jobs | If CSV file is large, Workato will split the CSV file into chunks and process them as separate Salesforce bulk jobs to comply with Salesforce API size limits. Each bulk job in the list will have the following data. | |
Job ID | Internal Salesforce ID of the Salesforce bulk job created | |
Number of records failed | Number of records failed to be processed successfully by Salesforce | |
Number of records processed | Number of records processed in total by Salesforce (i.e. number of rows in CSV file excluding header row) | |
List size | Synthetic field that tells us how many Salesforce bulk jobs were created in total |
The aggregated results across bulk jobs can be found at the top of the datatree.
Salesforce bulk operation output datatree - aggregated results across bulk jobs
The list of Salesforce bulk jobs can be found at the bottom of the datatree.
Salesforce bulk operation output datatree - list of bulk jobs
# Retry bulk job for failed records from CSV file
The retry action has a single input field CSV content with failed records that expects the CSV content with failed records datapill from a previous Salesforce bulk operation action. By passing that CSV content in, Workato will understand the previous configuration you have done (i.e. what your CSV file looks like, what Salesforce object to write to and how the CSV data should be mapped into Salesforce fields).
The retry action is synchronous. This means that the recipe will only continue to the next action when Salesforce has finished processing all CSV rows into Salesforce.
Configured Salesforce bulk retry action
# Example recipe
Let's go through an example recipe using the bulk create via CSV file action as well as the retry bulk job action.
Sample recipe - Salesforce bulk upsert via CSV file. Example recipe (opens new window)
The S3 trigger monitors new CSV files dropped into an S3 bucket, and we stream the data from the CSV file into Salesforce via the Create objects in bulk via CSV file Salesforce action. If this create operation is not fully successful, i.e. at least 1 CSV row did not get written into Salesforce successfully, we use the Retry objects bulk job in Salesforce via CSV file action to attempt to write the failed CSV rows into Salesforce again.
The Salesforce actions Create objects in bulk via CSV file and Retry objects bulk job in Salesforce via CSV file will manage large files for you. For large CSV files over a couple of GBs in size, Workato will chunk the CSV file into sizes under the Salesforce bulk API size limits and create multiple Salesforce bulk jobs.
The CSV file we use is as follows.
external_id,billing_country,phone,account_number
"a0K1h000003fXSS","United States of America","123 456 789","54"
"a0K1h000003fehx","Canada","650 894 345","12"
"a0K1h000003fjnv","Japan","103 948 414","28"
Here is the configured bulk create action.
Configured Salesforce bulk upsert action
Subsequently, the recipe checks to see if any records failed to be processed successfully by Salesforce. this could be due to many reasons such as:
- Data errors
- Records were locked as someone else/another process was editing them
- Network issues
If condition checking for any failed records
If any records failed, All records successfully processed? will be false
, and the recipe will proceed to carry out the retry action.
Configured retry bulk operation action
Last updated: 10/25/2024, 7:22:19 PM