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: 

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 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 to update the existing Contacts.  To prevent override data with nulls, check if the field is null before using it.