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
Nizam SaifiNizam Saifi 

Can I create person from pre chat popup window in live agent..?

I want to create person account from pre chat window customer details but getting created business account.

Please help me out my code is below for pre chat window form

<apex:page showHeader="false">

<!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
<script type='text/javascript'>
(function() {
function handlePageLoad() {
var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
document.getElementById('prechatForm').setAttribute('action',
decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
} if (window.addEventListener) {
window.addEventListener('load', handlePageLoad, false);
} else { window.attachEvent('onload', handlePageLoad, false);
}})();
</script>
<h1>Live Agent Pre-Chat Form</h1>

<!-- Form that gathers information from the chat visitor and sets the values to Live Agent Custom Details used later in the example -->
<form method='post' id='prechatForm'>

    Name: <input type='text' name='liveagent.prechat:AccountName' id='firstName' /><br />
     <!--input type='text' name='liveagent.prechat:ContactLastName' id='lastName' /><br /-->
     <!--input type='text' name='liveagent.prechat:ContactEmail' id='email' /><br /-->
    Phone: <input type='text' name='liveagent.prechat:AccountPhone' id='phone' /><br />
    Issue: <!--input type='text' name='liveagent.prechat:AccountDescription' id='subject' /--><br />

<!-- Hidden fields used to set additional custom details -->
    <input type="hidden" name="liveagent.prechat:AccountDescription" value="New-jkknj" /><br />
    <input type="hidden" name="liveagent.prechat:AccountRecordType" value="012a000000188SM" />
    <input type="hidden" name="liveagent.prechat.name" id="prechat_field_name" />

<!-- map: Use the data from prechat form to map it to the Salesforce record's fields -->
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,AccountName;Phone,AccountPhone;Description,AccountDescription;RecordType,'(!AccountRecordType)'"/><!--,AccountDescription;
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Phone,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Phone,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="Name,true;Phone,true;Description,true;RecordTypeId,True"/><!--;Bill_Street_1__c,true;
LastName,true;IsPersonAccount,true" /-->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true" />
<!--input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" /-->

<!-- saveToTranscript: Associates the records found / created, i.e. Contact and Case, to the Live Chat Transcript record. --> 
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="AccountId" />
<input type='submit' value='Chat Now' id='prechat_submit' onclick="setName()"/>

<!-- Set the visitor's name for the agent in the Console to first and last name provided by the customer -->
<script type="text/javascript">
   function setName() {
    document.getElementById("prechat_field_name").value =  
        document.getElementById("firstName").value;
    }
</script>

<style type="text/css">
p {font-weight: bolder }
</style>

</form>

thanks 

nizam

Best Answer chosen by Nizam Saifi
Magesh Mani YadavMagesh Mani Yadav
Hi Nizam,

Instead of using
Name: <input type='text' name='liveagent.prechat:AccountName' id='firstName' /><br />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,AccountName;Phone,AccountPhone;Description,AccountDescription;RecordType,'(!AccountRecordType)'"/>

Use this for Person Account
First Name: <input type='text' name='liveagent.prechat:AccountFirstName' id='firstName' /><br />
    Last Name: <input type='text' name='liveagent.prechat:AccountLastName' id='lastName' /><br />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,AccountFirstName;AccountLastName;Phone,AccountPhone;Description,AccountDescription;RecordType,'(!AccountRecordType)'"/>


Hope this solve your issue.

 

All Answers

Magesh Mani YadavMagesh Mani Yadav
Hi Nizam,

Instead of using
Name: <input type='text' name='liveagent.prechat:AccountName' id='firstName' /><br />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,AccountName;Phone,AccountPhone;Description,AccountDescription;RecordType,'(!AccountRecordType)'"/>

Use this for Person Account
First Name: <input type='text' name='liveagent.prechat:AccountFirstName' id='firstName' /><br />
    Last Name: <input type='text' name='liveagent.prechat:AccountLastName' id='lastName' /><br />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="Name,AccountFirstName;AccountLastName;Phone,AccountPhone;Description,AccountDescription;RecordType,'(!AccountRecordType)'"/>


Hope this solve your issue.

 
This was selected as the best answer
Nizam SaifiNizam Saifi
Thanks Mr Yadav for giving your valuable time to replied my question and its working very fine.
 
Laura McCraven at ACNLaura McCraven at ACN
Why this RecordType,'(!AccountRecordType)' vs this RecordTypeId,AccountRecordType when mapping the values? 

I cannot get this to work and I can't figure out why. If I remove the reference to Person Email and Record Type ID, it creates a business account. If the Person Account exists, it matches up fine. But I can't get my code to actually create a Person Account. Any ideas why?

If I leave my code like yours with the (!AccountRecordType), it creates as a business account with no Record Type set.. if I have it as RecordTypeId,AccountRecordType.. it doesn't create at all.