Notes
In Salesforce Apex, the upsert
statement is used for upserting records, which means updating existing records if they exist or inserting new records if they don't. The decision to update or insert is based on a record ID.
Here's a brief overview of how upsert
works:
Contact con1 = new Contact(FirstName='Josh', LastName='Kaplan', Department='Finance');
insert con1;
con1.Description = 'This contact is updated after insertion.';
Contact con2 = new Contact(FirstName='Kathy', LastName='Brown', Department='Technology');
upsert new List<Contact>{con1, con2};
Video
Video does not exists.