You need to sign in to do that
Don't have an account?
Zach Bratcher
Contact Upsert
I am currently working on building a custom visual force page that will upsert new contact records. The issue I am not able to get it to update the record. It does create new records and if the email already exists and the user clicks on submit the page just blinks and does nothing. Here is the APEX code I have for the upsert.
public class NewAndExistingController { public Contact contact { get; private set; } public NewAndExistingController() { Id id = ApexPages.currentPage().getParameters().get('id'); contact = (id == null) ? new Contact() : [SELECT id, firstname, lastname, phone, email, MailingStreet, MailingPostalCode, MailingState, birthdate, TargetX_SRMb__Campus__c, TargetX_SRMb__Program__c, Dual_Enrollment__c, TargetX_SRMb__Gender__c, Attended_College_Previously__c, Attended_TSTC_Previously__c, Reason__c, Preferred_Method_of_Contact__c, Preferred_Name__c, High_School2__c, Previous_College__c FROM Contact WHERE Id = :id]; } public PageReference save() { try { upsert contact; } catch(System.DMLException e) { ApexPages.addMessages(e); return null; } // After successful Save, navigate to the default view page PageReference redirectSuccess = new PageReference('http://google.com'); redirectSuccess.setRedirect(true); return (redirectSuccess); } }
It appears to be an issue with redirection to me. I recommend doing a Network Capture to troubleshoot this further