I have a spread sheet from the business to load contacts and a related child object to contact. The business wants to load the contacts by the below matching criteria.

First Name, Last Name, Phone First Name, Last Name, Email

Basically, we need to update the existing contact in Salesforce if the data in the spread sheet matches with the first name, last name and Email or Phone of an existing contact. If there is no match, we need to insert a new contact.

So, we need to do the upsert based on First Name, Last Name and (Phone or Email).

Any suggestions on how to achieve this?

1 Answer 1


Not sure if this is the best solution for this use case, but there is a programmatic solution for this.

You can zip the csv file and upload it as a static resource, then you can get it via Apex and parse it, something like this:

StaticResource sr = [SELECT Id,SystemModstamp FROM StaticResource WHERE Name = 'leads'];
String srPath = '/resource/' + sr.SystemModstamp.getTime() + '/leads/newLeads.csv'; 
PageReference pr = new PageReference(srPath);
String leadsCsv = pr.getContent().toString();   //get the content as string

Now you can extract the new leads from the string and put them in lead records, then pull the existing leads records from the DB and you can compare between the old and new records.

  • So, there is no way to achieve this without apex? Commented Jan 13, 2021 at 18:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .