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
LeadInternetLeadInternet 

What's the most efficient way to lookup Salesforce Id's of hundreds of records based on custom Ids?

I have a file that has around 300 records that needs to be processed daily. Each record has a custom Id and other attributes that need to be updated. My original approach was to lookup each record individually to find the Salesforce Id and then do the update. It appears that I'm running into api limits with this approach.

 

Second thought was to lookup multiple records at once using something like:

 

SELECT Id, ThirdParty_ID FROM Lead WHERE ThirdParty_ID IN ('ID10124' , 'ID10359' , 'ID10548')
 
I'd like to know the most efficient way / best practices to lookup multiple records using the web service api to limit my api calls?
 
Thanks,
Matt

LeadInternetLeadInternet

Turns out it was not an api limit. But I'm still curious what would be the most effective way to lookup Ids and limit the number of api calls.

 

-Matt

SuperfellSuperfell
Depends on what processing your doing once you've got the Ids, but using upsert and/or the foreign key resolution using external Ids may let you skip the entire lookup Ids process entirely.
LeadInternetLeadInternet

Thanks Simon. This helps lead me in the right direction.

 

I'm trying to update records in the standard Lead object. One of the fields in the record is marked as an "External ID" field which means I could use it in the upsert() call and avoid the lookup. But, the upsert will insert any leads that don't exist and I only want records updated.

 

Is it possible to specify the "External ID" field alone (instead of the Id field) in the update() call as in below. Note that the External ID field is not marked as unique:

 

Lead lead = new Lead();
lead.External_Id__c = ExternalId; // field marked as External ID
lead.Name = "New Name"; // new name

SaveResult[] saveResults = sforceService.update(new sObject[] { lead });

Thanks,
Matt

 

VarunCVarunC

 


LeadInternet wrote:

Thanks Simon. This helps lead me in the right direction.

 

I'm trying to update records in the standard Lead object. One of the fields in the record is marked as an "External ID" field which means I could use it in the upsert() call and avoid the lookup. But, the upsert will insert any leads that don't exist and I only want records updated.

 

Is it possible to specify the "External ID" field alone (instead of the Id field) in the update() call as in below. Note that the External ID field is not marked as unique:

 

Lead lead = new Lead();
lead.External_Id__c = ExternalId; // field marked as External ID
lead.Name = "New Name"; // new name

SaveResult[] saveResults = sforceService.update(new sObject[] { lead });

Thanks,
Matt

 


 

Did this code with External ID worked for you?

 

new joinersnew joiners

hello i am new to this salesforce developer how to use  standarad object and how many ways we can insert the standarad object s in the salesforce.com

 

how to develop the coding in  salesforc e plz help me