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
Chris over 9000Chris over 9000 

LiveAgent findOrCreate.map.doCreate - will it work with Person Accounts

The documentation at http://developer.chatter7bk.com/docs/atlas.en-us.salesforce1api.meta/salesforce1api/live_agent_creating_records_prechat_API_doCreate.htm gives the example of a contact and http://peterknolle.com/live-agent-pre-chat-api/ gives some really good code examples (again for contacts) but my org is using person accounts almost exclusively. Does it work with person accounts and does anybody know the syntax?
Best Answer chosen by Chris over 9000
Jason Cooke 2Jason Cooke 2
You can use LiveAgent to create the Account and pass across the recordtype for the Person Account.


<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="FirstName,First Name;LastName,Last Name;PersonEmail,Email;BillingPostalCode,Zip;Type,Customer Type;RecordTypeId,'{!PersonRTId}'" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="FirstName,true;LastName,true;PersonEmail,true;BillingPostalCode,true;Type,true;RecordTypeId,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="AccountId" />

When the record is created it will return the AccountId, the ContactId is always null for the new Person Account.  We've had problems linking the new Person Account to a Case using the PreChat API.  The Account is assigned, but the Contact is null.  To get around this, we have a trigger on the Case to update the Contact Id if the Account is a person account.

All Answers

Jason Cooke 2Jason Cooke 2
You can use LiveAgent to create the Account and pass across the recordtype for the Person Account.


<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="FirstName,First Name;LastName,Last Name;PersonEmail,Email;BillingPostalCode,Zip;Type,Customer Type;RecordTypeId,'{!PersonRTId}'" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Account" value="FirstName,true;LastName,true;PersonEmail,true;BillingPostalCode,true;Type,true;RecordTypeId,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Account" value="AccountId" />

When the record is created it will return the AccountId, the ContactId is always null for the new Person Account.  We've had problems linking the new Person Account to a Case using the PreChat API.  The Account is assigned, but the Contact is null.  To get around this, we have a trigger on the Case to update the Contact Id if the Account is a person account.
This was selected as the best answer
Jason Cooke 2Jason Cooke 2
PersonRTId is the Id for the Account "Person Account" recordtype.  We're passing this across through the controller.
Chris over 9000Chris over 9000

I'm guessing that the key,value; groupings would look something like 

FirstName,John;LastName,Smith;PersonEmail,smith@example.com;BillingPostalCode,90210;
Jason Cooke 2Jason Cooke 2
This is how we're passing the values across - we're using a PreChat form to collect the details and doing some validation in VF then using those on the LiveAgent api:

<input type="hidden" name='liveagent.prechat:First Name' value="{!sFirstName}"/>
<input type="hidden" name='liveagent.prechat:Last Name' value="{!sLastName}"/>
<input type="hidden" name='liveagent.prechat:Email' value="{!sEmail}"/>
<input type="hidden" name='liveagent.prechat:Zip' value="{!sZip}"/>
<input type="hidden" name='liveagent.prechat:Customer Type' value="{!sUserType}"/>
<input type="hidden" name='liveagent.prechat:Company' value="{!sCompany}"/>
<input type="hidden" name='liveagent.prechat:Button' value="{!sRecordType}"/>