+ Start a Discussion
chandrapchandrap 

Create Contact Before Creating a Case

Hi,

 

I'm trying to implement the feature 'Web to Case'. I've a form published in my web site and when the user submits the form its creating a case in my Sanbox. But since the user is not a contact in Salesforce, contact email and contact phone fields are not getting populated. I want to have the email field populated so that when I update the case it will trigger an email to the end user who logged the case online.

 

How can I pass the email and phone number from the form (from web site) to an Apex trigger to create the contact before creating a Case. I'm not sure whether this is possible. If that is possible, please guide me to accomplish it. Also let me know if there is any other way to create a Contact on the fly before creating a Case [through Web to Case].

 

Thanks

 

paul-lmipaul-lmi
we did this by implementing an afterinsert trigger on the case object that takes the suppliedemail, suppliedname, and supplied phone fields and creates a new contact with them, and then updates the case with the newly created contactid.  i'd post code here, but it's way more complex than what you're looking for.  but, to answer your question, yes it is possible.
chandrapchandrap

Thanks Paul. Can you please post the code, so that I can proceed further as I'm new to Apex development.

 

Thanks

chandrapchandrap
How do I pass data from my form to the trigger under Case in order to create the contact?
sHollersHoller
Do you think that you could actually post this code?  I'm trying to do the same thing but stumbling a little bit on it
chandrapchandrap
Yes it is. It is now posting the data and its getting populated in my case. I'm trying to pass the data to a trigger so that I can create a contact and populate the contact fields in the case which was created.
chandrapchandrap
Can someone post a sample code to create a Contact before creating the case in Web to Case feature?
DCCFundDCCFund

Yes. If someone can post some code for this process it would be very helpful. 

 

This "issue" seems like an oversight, but it has been around for years.