In Salesforce data management, the task of uploading CSV records can pose significant challenges, especially when dealing with large volumes of data. Salesforce’s limitations, such as upserting only 200 records simultaneously, can lead to time-consuming processes. In this blog, we explore a solution that not only overcomes these limitations but also significantly enhances efficiency—the Bulk API V2.
Challenges with traditional approaches
When upserting records in Salesforce, especially in large quantities, you may have encountered errors and faced challenges. Traditional approaches, like parallel or batch jobs, work well for small datasets (e.g., 5k or 10k records). However, when dealing with substantial CSV data, a more robust solution is needed.
The below example shows how to upsert records using the Salesforce upsert connector, and the associated error.
Upon upserting the records in Salesforce, you must have experienced the below error.
Bulk API V2: A Game-Changer
To overcome the limitation and streamline the process, we can leverage the power of Bulk API V2. This blog will guide you through the process of uploading CSV records to Salesforce using Bulk API V2. Let’s dive into the details.
1. Create Job Bulk API V2
The initial step involves creating a job in Salesforce using the ‘Create job bulk API V2’ connector. This involves converting data into a CSV format and initiating a job in Salesforce. The resulting job status provides vital information, including the job ID, current status (in progress, completed, or failed), and other details.
{
“id”: “7505j00000KOpn1AAD”,
“state”: “InProgress”,
“object”: “Contact”,
“operation”: “upsert”,
// … other fields …
}
The job status provides a comprehensive overview:
- id: The job ID is one of the important fields in the above status. It can be used to retrieve successful records, failed records and the job’s status.
- status: This field indicates the current job status is failed, in progress or completed.
2. Check the Job Status
After creating the job, it’s crucial to check its status. This can be done by passing the job ID to the appropriate endpoint. The retrieved status informs you whether the job is still in progress, completed successfully, or has failed.
Response:
3. Retrieve Successful and Failed Records
To ensure a thorough data integration experience, Bulk API V2 provides connectors to retrieve successful and failed records. By passing the job ID to the corresponding endpoints, you can retrieve a comprehensive list of successful and failed records.
The below example shows how to retrieve failure records:
Response:
The below example shows how to retrieve successful records:
Response:
Conclusion: Enhancing Salesforce Efficiency
Incorporating Bulk API V2 into your Salesforce data uploading strategy is a strategic move to address limitations associated with record volume. From job creation to handling different job statuses, I hope you’ve gained valuable insights into optimising Salesforce processes for a smoother data integration experience.
Stay tuned for more insights and tips on maximising the potential of Salesforce.
Reference link: Bulk API and Bulk API 2.0 Limits and Allocations