+ Start a Discussion
PeacePeace 

upsert steps

Hi,

 

I am new to Salesforce.  Please help me in implementing upsert functionality:

 

I have implemented functionality to insert records from 'csv file' to 'Salesforce Standard and Custom objects'.

Now, when i try to insert those records again after few changes, i want that missing records should be inserted and existing records should be updated using the external id,  ie. UPSERT functionality.

 

Please provide me steps to implement this, and apex code if any?

 

Thanks

Yoganand GadekarYoganand Gadekar

Try like this;

 

List<Account> acctList = new List<Account>();
// Fill the accounts list with some accounts

 

try {
    upsert acctList;
} catch (DmlException e) {
  
}

 

Thanks;

Avidev9Avidev9

What do you mean by CSV?
Standard Import wizard or dataloader ?
Or your own custom solution ?

For data loader : http://blog.ryansieve.com/2013/03/14/using-salesforce-com-data-loader-upsert-with-an-external-id/


souvik9086souvik9086

You can use the upsert functionality while uploading data. You can match as well the salesforce record id or external id. 

Click upsert, then in "Select the fields for matching". You choose ID or External ID,

Then in the field map you map ID -> ID OR External_ID -> External_ID

It means new record will be inserted and old ones will be updated. Make sure the ID in csv of those are updating must be the organisation id in which you are uploading.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

PeacePeace

hi,

 

I dont want to use Standard import wizard or Data loader.

I want to build my own custom solution.

Can anyone  please provide an example ?