Form Issues related to Salesforce

  • Started
  • Last post
  • 6 Responses
  • ChickenCrab

    Our company recently signed up with Salesforce.com and I'm trying to incorporate their web-to-lead form into our existing ColdFusion forms. The outcome of this would mean that anyone who submits a form on our website automatically has their contact info added to our lead database on Salesforce.

    Our current forms run both pop-up Javascript-based and then ColdFusion-based error handling, then send an email. From what I can gather, I think I'll need to write a script that will both send an email like normal and post the data to Salesforce after the error handling. So it'll look like this:

    1. User fills out and submits form
    2. Javascript error handling
    3. If Javascript is off, Coldfusion error handling
    4. Once information is error free, run a script to:
    * Send a notification email to company owner
    * Submit contact information to Salesforce web-to-lead database

    Though it seems like it's probably simple enough, I don't really know enough about coding to write this script - if that's really what I need to do. Any help would be most appreciated.

  • ChickenCrab0

    --------------------------------...
    In order to submit the info to Salesforce, I would need to add these to my form (as well as change my existing input names to their standards):
    --------------------------------...

    <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
    <input type=hidden name="oid" value="000000000000">
    <input type=hidden name="retURL" value="http://www.companyname.com/thankyou.html">

  • ChickenCrab0

    --------------------------------...
    This is the first part of our existing form and goes above the opening html tag for processing.
    --------------------------------...

    <!--- FORM PROCESSING --->
    <!--- Add cfparams to prevent errors on the page --->
    <cfparam name="FORM.Name" default="">
    <cfparam name="FORM.Company" default="">
    <cfparam name="FORM.Email" default="">
    <cfparam name="FORM.Phone" default="">
    <cfparam name="FORM.Products" default="">
    <cfparam name="FORM.Comments" default="">
    <!--- Set the length of the text string for the CAPTCHA image. --->
    <cfset stringLength=6>
    <!--- Specify the list of characters used for the random text string. The following list limits the confusion between upper- and lowercase letters as well as between numbers and letters. --->
    <cfset stringList="2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z">
    <cfset rndString="">
    <!--- Create a loop that builds the string from the random characters. --->
    <cfloop from="1" to="#stringLength#" index="i">
    <cfset rndNum=RandRange(1,listLen(stringList))>
    <cfset rndString=rndString & listGetAt(stringList,rndNum)>
    </cfloop>
    <!--- Hash the random string. --->
    <cfset rndHash=Hash(rndString)>
    <!--- Create an empty error string --->
    <cfset strError = "">
    <!--- Create an string to show the form and set it to true--->
    <cfset showForm = "true">
    <!--- If the form is submitted --->
    <cfif isDefined("FORM.doForm") AND FORM.doForm EQ "true">
    <!--- If the Name field is empty --->
    <cfif Len(Trim(FORM.Name)) LT 1>
    <!--- Add this to the error string --->
    <cfset strError = strError & "Please enter your name.<br>">
    </cfif>
    <!--- If the Company field is empty --->
    <cfif Len(Trim(FORM.Company)) LT 1>
    <!--- Add this to the error string --->
    <cfset strError = strError & "Please enter your company name.<br>">
    </cfif>
    <!--- If the Email field is empty --->
    <cfif Len(Trim(FORM.Email)) LT 1>
    <!--- Add this to the error string --->
    <cfset strError = strError & "Please enter your email address.<br>">
    </cfif>
    <!--- If the Email field is not valid --->
    <cfif IsValid("email", FORM.Email)>
    <!--- Add this to the error string --->
    <cfelse>
    <cfset strError = strError & "Please check that the email address you entered is valid.<br>">
    </cfif>
    <!--- If the moreInformation text input is changed a robot is trying to SPAM --->
    <cfif Trim(FORM.moreInformation) NEQ "More information here!">
    <!--- Add this to the error string --->
    <cfset strError = strError & "SPAM, SPAM, SPAM, SPAM!<br>">
    </cfif>
    <!--- If the CAPTCHA values are not equal --->
    <cfif #FORM.hashVal# NEQ Hash(#FORM.capText#)>
    <!--- Add this to the error string --->
    <cfset strError = strError & "The captcha text does not match the image. Please check it again and remember that it is case sensitive.<br>">
    </cfif>
    <!--- If the error string is still empty --->
    <cfif strError EQ "">
    <!--- Set showForm as false --->
    <cfset showForm = "false">
    <!--- Send the email --->
    <cfmail


    cc=""
    replyto="#FORM.Email#"
    subject="GM - Contact Us"
    server="mail.companyname.com">
    NAME: #Trim(FORM.Name)#
    COMPANY: #Trim(FORM.Company)#
    EMAIL: #Trim(FORM.Email)#
    PHONE: #Trim(FORM.Phone)#
    INTERESTED IN: #Trim(FORM.Products)#
    COMMENTS: #Trim(FORM.Comments)#
    </cfmail>
    </cfif>
    </cfif>
    <!--- END FORM PROCESSING --->

  • ChickenCrab0

    --------------------------------...
    This is our form code.
    --------------------------------...

    <!--- BEGIN FORM --->
    <cfform id="contactForm" name="contactForm" method="post" action="#CGI.SCRIPT_NAME#">
    <table id="form_table">
    <tr>
    <td>
    <!--- Name --->
    <cfinput
    class="form_area"
    type="text"
    name="Name"
    id="Name"
    required="yes"
    message="Please enter your name."
    value="#Trim(FORM.Name)#" /><br />
    <label>Name*</label></td>
    <td>
    <!--- Company --->
    <cfinput
    class="form_area"
    type="text"
    name="Company"
    id="Company"
    required="yes"
    message="Please enter your company's name."
    value="#Trim(FORM.Company)#" /><br />
    <label>Company*</label></td>
    </tr>
    <tr>
    <td>
    <!--- Email --->
    <cfinput
    class="form_area"
    type="text"
    name="Email"
    id="Email"
    required="yes"
    validate="email"
    message="Please check that you entered your email address and that it is valid."
    value="#Trim(FORM.Email)#" /><br />
    <label>Email*</label></td>
    <td>
    <!--- Phone --->
    <cfinput
    class="form_area"
    type="text"
    name="Phone"
    id="Phone"
    required="no"
    message="Please enter your phone number."
    value="#Trim(FORM.Phone)#" /><br />
    <label>Phone</label></td>
    </tr>
    <!--- Checkboxes --->
    <tr>
    <td colspan="2"><div class="form_subhead">I am interested in the following product offering(s):</div></td>
    </tr>
    <tr>
    <td>
    <label><input type="checkbox" name="Products" value="Brand Development" />Brand Development</label><br />
    <label><input type="checkbox" name="Products" value="Market Planning" />Market Planning</label><br />
    <label><input type="checkbox" name="Products" value="Creative Services" />Creative Services</label>
    </td>
    <td>
    <label><input type="checkbox" name="Products" value="Web Services" />Web Services</label><br />
    <label><input type="checkbox" name="Products" value="Public Relations" />Public Relations</label><br />
    &nbsp;
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <!--- Comments --->
    <cftextarea
    class="form_area2"
    name="Comments"
    id="Comments"
    rows="6"
    cols="15"
    required="no"
    message="Please enter a comment.">
    <cfoutput>#Trim(FORM.Comments)#</cfoutput></cftextarea><br />
    <label>Comments</label></td>
    </tr>
    <tr>
    <td>
    <!--- Hidden field with CAPTCHA VALUE --->
    <cfinput
    type="hidden"
    name="hashVal"
    id="hashVal"
    value="#rndHash#">
    <!--- Image holding CAPTCHA VALUE --->
    <cfimage
    action="captcha"
    fontsize="24"
    fonts="Arial"
    width="200"
    height="50"
    text="#rndString#"></td>
    <td><div class="required">AREAS MARKED WITH AN ASTERISK (*) ARE REQUIRED.</div></td>
    </tr>
    <tr>
    <td class="bottom_row">
    <!--- capText text input - REQUIRED --->
    <cfinput
    class="form_area"
    type="text"
    name="capText"
    id="capText"
    required="yes"
    message="The captcha text does not match the image. Please check it again and remember that it is case sensitive." /><br />
    <label>Captcha Text* (case sensitive)</label></td>
    <td class="bottom_row" align="right">
    <!--- Hidden field used to tell server to process form --->
    <cfinput
    type="hidden"
    name="doForm"
    id="doForm"
    value="true">
    <div class="special">
    <input
    type="text"
    name="moreInformation"
    id="moreInformation"
    value="More information here!" />
    </div>
    <!--- Submit button --->
    <cfinput
    class="submit_button"
    type="submit"
    name="Submit"
    id="Submit"
    value="SUBMIT" /></td>
    </tr>
    </table>
    </cfform>
    <!--- End ColdFusion Form --->
    <!--- Show the form results if showForm is set to false --->
    <cfelse>
    <cflocation url="/thanks_contact.cfm">
    </cfif>
    <!--- END FORM --->

  • grunttt0

    bump

  • grunttt0

    rebump

  • ChickenCrab0

    up