• CharleneS
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi,

I am trying to link a prechat form up to existing Accounts when it comes to Person Accounts. What is happening currently is regardless of details added the system is making a new account with contactId, what I need it to do is link up matching details (which is seems to not be able to manage) I looked at this thread but have not been successful at replicating the results.

The code I have used comes from the dev docs, edited to use Person Account.
 
<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'>
    First name: <input type='text' name='liveagent.prechat:AccountFirstName' id='firstName' /><br />
    Last name: <input type='text' name='liveagent.prechat:AccountLastName' id='lastName' /><br />
    Email: <input type='text' name='liveagent.prechat:AccountEmail' id='email' /><br />
    ZipCode: <input type='text' name='liveagent.prechat:AccountZipCode' id='zipcode' /><br />
    
    <!-- Used to set the visitor's name for the agent in the Console -->
    <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="FirstName,AccountFirstName;LastName,AccountLastName;Email,AccountEmail;ZipCode,AccountZipCode;RecordTypeId,'{!PersonRTId}'"" />

<!-- doFind, doCreate and isExactMatch example for a Account: 
    Find a Account whose Email exactly matches the value provided by the customer in the form 
    If there's no match, then create a Account record and set it's First Name, Last Name, Email, and ZipCode to the values provided by the customer -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="Email,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="Email,true" />

<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" />

<!-- showOnCreate: Open the Account records as sub-tabs to the chat for the agent in the Console -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true" />

<!-- saveToTranscript: Associates the records found / created, i.e. Account, 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 + " " + document.getElementById("lastName").value;
    }
</script>

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

</form>
</apex:page>

Any help will be appreciated in getting this to map correctly!

Kind regards,

Charlene