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
CustomDataIntegrationsCustomDataIntegrations 

How do I call the Bulk API from my Controller?

How do I go about sending my batches to the Bulk API?  Can someone give me an example or point me to one? 

I am developing an application in SalesForce.  At one point, I make a call out to an outside webservice which returns some that I load to a file.  I load this into a Document and save it to the user documents, but there is also some data that is returned that I want to use to update records with.  I have been reading about the Bulk API, but I do not quite understand how I would call this from my controller.  I understand the limits and batches and that in my case, I will have to batch my updates.  

 

sfdcfoxsfdcfox

It would be tough to call an async call in controller code, but you can do it with a hidden timer on the Visualforce page.

 

You'll probably need the following functions:

 

1) createJob(): creates a new job.

2) retrieveJob(): get details about the job.

3) closeJob(): finalizes the job.

4) addBatch(): adds a batch to the job.

5) retrieveBatch(): gets information about the batch.

 

Assuming you have all this, most of the actual processing won't be in your controller due to constraints. You will need some JavaScript to package up the data, then call these functions in the desired order (via @RemoteAction or actionFunction). It is certainly "doable", but I think you're asking for a lot of trouble.

 

Maybe you should start back at the beginning... what is your intent? What are you trying to do? How do you expect the user to interface with your desired functionality? Maybe there's a different approach you can take to your desired objective without trying to get the Bulk API working.