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
3C3C 

Why is pre-chat form not creating new lead record?

Here is my form code. I'm trying to create a lead record from the pre-chat form if one does not already exist.

<form method='post' id='prechatForm'>
    First Name:<font color="red">*</font><input type="text" name="liveagent.prechat:FirstName" /><br />
    Last Name:<font color="red">*</font> <input type="text" name="liveagent.prechat:LastName" /><br />
    Email:<font color="red">*</font> <input type="text" name="liveagent.prechat:Email" /><br />
    Phone Number:<font color="red">*</font> <input type='text' name='liveagent.prechat:Phone' /><br />
    Company Name:<font color="red">*</font> <input type='text' name='liveagent.prechat:Company' /><br />
    State:<font color="red">*</font> <select name="liveagent.prechat:State">
          <option value='Select State' selected='selected'>Select State</option>
          <option value='AK'>AK</option>
          <option value='AL'>AL</option>
          <option value='AR'>AR</option>
          <option value='AZ'>AZ</option><option value='CA'>CA</option><option value='CO'>CO</option><option value='CT'>CT</option><option value='DE'>DE</option><option value='FL'>FL</option><option value='GA'>GA</option><option value='HI'>HI</option><option value='IA'>IA</option><option value='ID'>ID</option><option value='IL'>IL</option><option value='IN'>IN</option><option value='KS'>KS</option><option value='KY'>KY</option><option value='LA'>LA</option><option value='MA'>MA</option><option value='MD'>MD</option><option value='ME'>ME</option><option value='MI'>MI</option><option value='MN'>MN</option><option value='MO'>MO</option><option value='MS'>MS</option><option value='MT'>MT</option><option value='NC'>NC</option><option value='ND'>ND</option><option value='NE'>NE</option><option value='NH'>NH</option><option value='NJ'>NJ</option><option value='NM'>NM</option><option value='NV'>NV</option><option value='NY'>NY</option><option value='OH'>OH</option><option value='OK'>OK</option><option value='OR'>OR</option><option value='PA'>PA</option><option value='RI'>RI</option><option value='SC'>SC</option><option value='SD'>SD</option><option value='TN'>TN</option><option value='TX'>TX</option><option value='UT'>UT</option><option value='VA'>VA</option><option value='VT'>VT</option><option value='WA'>WA</option><option value='WI'>WI</option><option value='WV'>WV</option><option value='WY'>WY</option>
        </select><br />
        <br/><font color="red">*</font>Indicates a required field.<br /><br />
        <!-- Saves values entered in the pre-chat fields to the chat transcript -->
        <input type="hidden" name="liveagent.prechat.save:FirstName" value="First_Name__c" />
        <input type="hidden" name="liveagent.prechat.save:LastName" value="Last_Name__c" />
        <input type="hidden" name="liveagent.prechat.save:Email" value="Email__c" />
        <input type="hidden" name="liveagent.prechat.save:Phone" value="Phone__c" />
        <input type="hidden" name="liveagent.prechat.save:Company" value="Company__c" />
        <input type="hidden" name="liveagent.prechat.save:State" value="State__c" />
       
<!-- Map lead fields  -->
<input type="hidden" name="liveagent.prechat.findorcreate.map:Lead" value="FirstName,FirstName;LastName,LastName;Email,Email;" />

<!-- Match lead by email -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Lead" value="Email,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Lead" value="Email,true;" />

<!-- Create unmatched lead -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Lead" value="FirstName,true;LastName,true;Email,true;" />

<!-- Save lead to lookup -->
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Lead" value="Lead" />

<!-- Display lead -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Lead" value="true" />

    <input type='submit' value='Request Chat' id='prechat_submit'/> 
</form>
Ashish_SFDCAshish_SFDC

Hi Cortney, 


You have to use a Lead Standard Controller for the implementation. 

Enable debug logs and look for logs and see if you find any errors or break in the execution. 

See a sample below, 

https://developer.salesforce.com/forums?id=906F000000099KDIAY

http://iwritecrappycode.wordpress.com/2013/10/29/salesforce-live-agent-review-customization/


Regards,

Ashish

sandhubalssandhubals
Simplest test would be:
1. Creating the lead by loging in as an Agent
2. When creating the lead via liveagent.prechat API make sure all the mandatory fields are captured or being populated on the Prechat form as were populated when creating the lead from UI
3. If nothing works, use debug logs
Patrick KloiberPatrick Kloiber
sandhubals you were spot on with mentioning the required fields.  I was having this same issue and then reviewed the required fields on our lead ui and noticed that i was not passing in the lead status.  By not passing this in, the lead creation via api in live agent was not working.  once i passed it in, it immediately worked.  Thanks for the comment.