function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel Rudman 7Daniel Rudman 7 

Bulk API v2

Hi,
Thanks in advance for any help and advice. So we are building a data integration using Bulk API v2, but now we have a big concern as to how we can match up the record ID's returned for insert operations to the records which were sent.

https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/get_job_successful_results.htm

Usage Notes
The order of records in the response is not guaranteed to match the ordering of records in the original job data.

First, not sure when exactly the order is not guaranteed. If all records insert succesfully, the order does seem to match.

Second, when some records fail, then the order of course does not match, because the failed records are now in the failed results endpoint. 
So lets say you send in for insert:

Test account 1
Test account 2
Test account 3

And account 2 fails. then the success endpoint for bulk api v2 will return Test account 1 and Test account 3. The failure endpoint will return Test account 2. But there is no way to trace them to the original records we were inserting. how does Salesforce expect that to work?

With Bulk API v1 the results were returned in one list which matched up to the order of the records which were sent in, with the last containing both success and failure.

Is it possible to do this?
ShirishaShirisha (Salesforce Developers) 
Hi Daniel,

Greetings!

You can see the records/data that you wanted to insert under view results of the jobs on  Bulk Jobs.Also,you should have the CSV file which will have the data that you wanted to insert into the salesforce in which you can check the data in case if you miss on the "View Results" link in salesforce.

Also,please refer the document (https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/walkthrough_upload_data.htm) for the steps to insert the records in bulk.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri

 
Daniel Rudman 7Daniel Rudman 7
Hi, thanks for the response but this does not quiet help. See my scenario above, there is no way to map back the results to the source records. yes i know where to find the results and i do have the source csv i am ingressing, but how to figure out which source records maps to a failed or successfull record. in bulk api v1 one big result list is returned, with successes and failures combined, so you can precicesly map the source record to the results. But not in bulk api v2.
Daniel Rudman 7Daniel Rudman 7
Hi, thanks for the response but this does not quiet help. See my scenario above, there is no way to map back the results to the source records. yes i know where to find the results and i do have the source csv i am ingressing, but how to figure out which source records maps to a failed or successfull record. in bulk api v1 one big result list is returned, with successes and failures combined, so you can precicesly map the source record to the results. But not in bulk api v2.
ShirishaShirisha (Salesforce Developers) 
Hi Daniel,

If you can see any failed record in the file that you can see when you click on the View Results link.I would suggest you to copy the Id or record Name and look for that in the CSV file which you had with you to get the exact record and make changes accoridngly which is the only way to map the records.

Thank you!
Daniel Rudman 7Daniel Rudman 7
Thats exactly the issue. The failed CSV has no ID, which makes sense because these records were not inserted. The name is not guaranteed to be unique.

So the question still stands unfortunately, how to uniquely match it up?
ShirishaShirisha (Salesforce Developers) 
Understood the scenario completly but there is no other possible option to map the records with the CSV file other than comparing it with the failed record values.

Do you have any other field like external Id or unique Id with which we can cut down the number of records and find the required one.

Thank you!
Daniel Rudman 7Daniel Rudman 7
Thanks. This is for an ISV app, so it is meant to be used by any organization, so a unique ID is not guaranteed. We will have ot get creative then. Just wanted to make sure we were not missing a built in feature for this.
Suhel CruiseSuhel Cruise
Hi Shirisha,

If any other Unique Id field is not present in an Object (Standard or Custom), which is quite common use case, the API seems to be unusable when there are mutiple records with same values (less probability in real environment but easy to create this scenario in test setup). Am I missing something here ?
Identify and retrying of failed INSERTs would be requirement of any application that intends to use this API.

Thanks,
Suhel
Suhel CruiseSuhel Cruise
Is Salesforce planning to address this issue and fix it in its Bulk v2 API through some patch/upgrade anytime soon ?