I am trying to upsert a contact conditionally if similar contact is found.
Step 1: Prepare new contact data Contact c = new Contact(lastname = 'test', email = 'firstname.lastname@example.org', externalId__c ='12345'); //Step 2: Check existing contacts for duplicates "with some exceptions (and hence I cannot use uniqueness on this field)" //Step 3: upsert upsert c externalId__c;
If any contact is found in step 2 logic and has same external Id, I should be still able to do the upsert, but donot overwrite existing contact email address.
I am trying not to do additional query but instead just remove the email field from being updated.
Any suggestions ? Thanks in advance