+ Start a Discussion
SF API 9SF API 9 

Best practices for mass updating records via SF API

What is the best way for me to update mass update all contacts/accounts/etc. that match some form of shared criteria? For example, changing the industry type of all Contacts that live in New York, or something like that.

Right now the marketing workflow I'm working on is:

1. Pull 200 individual contacts from SF
2. Use each contact's ZIP and industry to create a specific marketing offer URL via 3rd party API
3. Create an array of contact objects using the SF ID and new marketing offer field data
4. Batch update() the contacts back into SF

It works great, but I'm realizing that there's a lot of overlap of API calls for me processing multiple contacts with the same ZIP and industry. Is there any way for me to refactor this pipeline to look more like this?

1. Query SF for all possible combinations of ZIP and industry
2. Find new corresponding marketing offer URL via 3rd party
3. Update all Contacts' offer URL to be that value, for all contacts that have matching ZIP and industry

If it were feasible to do this in SOQL, it'd basically look something like this:
UPDATE Contact
SET OfferUrl = "http://offerurl.com/123"
WHERE Contact.ZIP = '11215' AND Contact.Industry = 'Aerospace';
but I know that won't work. Is there some equivalent functionality to mass update without a SOQL query?

 
Ashish DevAshish Dev
How do you call API to get URL through Apex?
SF API 9SF API 9
I'm currently using the PHP Toolkit.
SF API 9SF API 9
I'm currently accessing the API through the PHP Toolkit.