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
Tarun Kaushik 11Tarun Kaushik 11 

unable to Search existing Contact and related Account from Pre Chat Form

 
Hi All
When Agents accepts the Chat from Live Agent pre chat form, I want to Salesforce should pick it up and in Salesforce (Service Cloud Console) directly open the respective Account, Contact and “New Case” window.
However Right now all three screen are opening but not searching and displaying the detail page of existing records and related Accounts of the existing Contact
Below is the code I am using, Please suggest?
<!--
 - Created by tarkaushik on 09.11.2017.
 -->

<apex:page id="FCM_LiveChatForm" showHeader="false">

<html>
<head>
<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>
</head>
<body>
<form method="post" id="prechatForm">
<apex:pageBlock>  
 <apex:pageblocksection >
<!-- Detail inputs -->
First Name: <input type="text" name="liveagent.prechat:personFirstName" id='firstName'/><br />
Last Name: <input type="text" name="liveagent.prechat:personLastName" id='lastName'/><br />
Email: <input type="text" name="liveagent.prechat:personEmail" /><br />
Phone: <input type="text" name="liveagent.prechat:Phone" /><br />
 </apex:pageblocksection>
</apex:pageBlock>

<input type="hidden" name="liveagent.prechat:CaseStatus" value="New" /><br />
        <input type="hidden" name="liveagent.prechat:CaseOrigin" value="Chat" /><br />
        <input type="hidden" name="liveagent.prechat:CaseRecordType" value="0120Y000000yCt6"/>

            
	<!-- Try to find the Contact by email (exact match) -->  
	  <input name="liveagent.prechat.findorcreate.map:Contact" type="hidden" value="FirstName,ContactFirstName;LastName,ContactLastName;Email,ContactEmail;"/>
         <input name="liveagent.prechat.findorcreate.map.doFind:Contact" type="hidden" value="Email,true;"/>
         <input name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" type="hidden" value="Email,true;"/>
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true"/>  
        
<!-- Map the detail inputs to the Account fields and RecordTypeId will be changed based on the Org--> 
<input type="hidden" name="liveagent.prechat.findorcreate.map:Account" value="FirstName,personFirstName;LastName,personLastName;PersonEmail,personEmail;Phone,Phone;RecordTypeId,0120Y000000y6Ej;" />

<!-- Try to find the Account by email (exact match) -->
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Account" value="PersonEmail,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Account" value="PersonEmail,true;" />
<!-- Used to set the visitor's name for the agent in the Console -->
<input type="hidden" name="liveagent.prechat.name" id="prechat_field_name" />

<!-- Used to set the visitor's details in the Chat Transcript custom fields -->
        <input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat"/>
        <input type="hidden" name="liveagent.prechat.save:personFirstName" value="FCM_VisitorsFirstName__c" />
        <input type="hidden" name="liveagent.prechat.save:personLastName" value="FCM_VisitorsLastName__c" />
        <input type="hidden" name="liveagent.prechat.save:personEmail" value="FCM_VisitorsEmail__c" />
        <input type="hidden" name="liveagent.prechat.save:Phone" value="FCM_VisitorsPhone__c" />
 

<!-- Show the Account when it is found or created -->
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Account" value="true" />


<input type="submit" value="Request Chat" id="prechat_submit" onclick="setName()"/>

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

</form> 
</body>
</html>
</apex:page>