Header sample.gif

Here is a simple example of using ColdFusion to accept Leads from a web form. By using CF, you don't have to put your Salesforce.com Org Id as a form field in your web form and you can do quality checks on the data before posting the lead to your Salesforce.com organization. This example was adapted from the PHP version by Wayne Abbott.

<!--- Normally you'd have these basic fields contained in a form on your webpage --->
<cfscript>
	Form.leadSource = "Other";
	Form.firstName = "TestF";
	Form.lastName = "TestL";
	Form.title = "Test Title";
	Form.company = "Test";
	Form.email = "[email protected]";
	Form.phone = "555-4444";
	Form.street = "123 Main St.";
	Form.city = "St. Paul";
	Form.state = "MN";
	Form.zip = "55108";
</cfscript>

<!---do quality checks on the incoming data here.--->

<!---then bundle the request and send it to Salesforce.com--->
<cfhttp method="POST" url="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8">
<!---<cfhttpparam name="Campaign_ID" value="701500000008hsE" type="FORMFIELD">    EXAMPLE associating lead to a campaign --->
<!---<cfhttpparam name="00N50000001JNb7" value="03/05/2009" type="FORMFIELD">    EXAMPLE custom date field --->
<cfhttpparam name="lead_source" value="#Form.leadSource#" type="FORMFIELD">  
<cfhttpparam name="first_name" value="#Form.firstName#" type="FORMFIELD"> 
<cfhttpparam name="last_name" value="#Form.lastName#" type="FORMFIELD"> 
<cfhttpparam name="title" value="#Form.title#" type="FORMFIELD"> 
<cfhttpparam name="company" value="#Form.company#" type="FORMFIELD"> 
<cfhttpparam name="email" value="#Form.email#" type="FORMFIELD"> 
<cfhttpparam name="phone" value="#Form.phone#" type="FORMFIELD"> 
<cfhttpparam name="street" value="#Form.street#" type="FORMFIELD"> 
<cfhttpparam name="city" value="#Form.city#" type="FORMFIELD"> 
<cfhttpparam name="state" value="#Form.state#" type="FORMFIELD"> 
<cfhttpparam name="zip" value="#Form.zip#" type="FORMFIELD"> 
<cfhttpparam name="oid" value="" type="FORMFIELD">  <!--- Your Salesforce Org Id here --->
<cfhttpparam name="retURL" value="http://" type="FORMFIELD">   <!--- Your return url here --->
<cfhttpparam name="debug" value="0" type="FORMFIELD"> <!--- 1=send debug email, 0=no debugging --->
<cfhttpparam name="debugEmail" value="" type="FORMFIELD">  <!--- email for debugging --->
</cfhttp>
<cfoutput>#cfhttp.FileContent#</cfoutput><cfabort>

--Troy Pullis Mar 3, 2009