+ Start a Discussion
Devon AllaryDevon Allary 

Updating multiple records with separate API calls

Our company uses a project management tool to manage engagements after they've been won in Salesforce. I've set up an Apex callout that will request the status and other information on the engagement from the project management tool's API and will use that status to update Salesforce.

Each of the engagements needs its own separate API call. We might, at any given time, have thousands of open engagements and I need to update these every night.

I've set up a scheduable Apex class that runs a query to find all of the open engagements that are connected to the project management tool. Then, I just loop through the records and for each one I run the API call and update. This seemed to work in the testing phase, but now I have many more records and I'm getting a "Too many future calls: " error.

I was thinking about running a scheduled query beforehand and dividing all of the Salesforce engagements into groups of 50, then scheduling multiple updates of 50 records staggered by a couple of minutes. This doesn't seem like a very scalable, though. Does anyone know of a better way to do this?
Neha AggrawalNeha Aggrawal
Hi Devon,

I am not 100% sure, but batch class could work. I had created a schedulable class that called a batch class that in turned called the API class. I never received any error with thousands of records.

Let me know if that helps.
Thanks,
Neha

www.initaura.com - Everything Salesforce