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
Garrett SamuelsGarrett Samuels 

Autocreating Contacts from Web to Case and Autoupdating existing Contacts

I have created a test class and trigger based on the code here: https://developer.salesforce.com/page/Autocreating_Contacts_From_Web_To_Case?state=id 

It works to autocreate the contact record from web-to-case. However, how can I update the trigger to allow new web-to-case submissions to update Contact fields for matching/existing contacts? Likewise, if a new web-to-case submission has null field values, how would we prevent the null value to not overwrite the existing value of the related contact record? 
3 Creeks3 Creeks
Once you get through the for (Case caseObj:Trigger.new) loop, you know that all of the elements the Set caseObj are contacts that exist.  Create another loop that iterates over caseObj and match them up against against trigger.new to update the existing Contacts.  To prevent override data with nulls, check if the field is null before using it.