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
DharmikDharmik 

Migrate data from excel sheet, This is only possible if same records is not exist

Hi Folks, 

I have one excel sheet. Which holds old records(already in salesforce) and new records. I want to insert only new records in salesforce. but don't know how to do. So basically migration needs to do following steps. 

1) Travers row by row data in excel sheet.(In excel sheet there is no Record ID columns, only domain data).
2) Check data already presents in salesforce or not. 
3) If this totally new records then insert. and If this is old then to updation. 

Please let me know If you need more clarification.

Thank you!
SForceBeWithYouSForceBeWithYou
Export the records you already have in Salesforce from that table (Accounts, Contacts, whatever) and find a way of marking your existing sheet as to which records are already in Salesforce.  That way you can separate the two into update and insert calls.  You can do this by a unique combination of fields (Name + address, for example) even if you don't have the Salesforce ID for that record.  If you have an External ID field marked in the table, you can upsert using that. 
https://www.salesforce.com/us/developer/docs/api_rest/Content/dome_upsert.htm
DharmikDharmik
Thank you SForceBeWithYou for replying on this questions. 

Can we do it with the help of apex coding? Something like travers row by row data from excel sheet. Using if check prevents duplication. If same records exist in the system then do nothing otherwise insert data. However, I can understand that your provided approach is a good option, but I have few other requirements as well which are not possible by your suggested way. 

Thank you for you support and help!