Print this page

Live Agent chats create duplicate cases upon reconnection.

Knowledge Article Number 000239357
Description


If you are using the findOrCreate method from Live Agent to create records automatically, you may have noticed that when the chat session is disconnected and eventually reconnected to another agent, 
a duplicate record will be created.

The scenario to reproduce this issue is as follows:

  1. Set up live agent with a prechat form that uses the findOrCreate method to create a case. 
  2. In two different browsers, log two agents in that have the skill to receive a chat from the appropriate button. 
  3. Click to chat with one of the agents and see a case created with particular case number. 
  4. Close the browser of the agent currently engaged in the chat.
  5. After a few seconds the chat will be sent to your other agent, and a new case will be created.
Resolution

This is expected behavior from the Live Agent API, but you can prevent it by implementing the workaround below. 

  1. Create a new field in the case object (type Text and Unique). This field can be hidden in the page layout.
  2. In the prechat form, generate a unique value* and pass it as a hidden value. In the example below, we have decided to call this caseChatID.
<input type='hidden' name='liveagent.prechat:caseChatID' id='chatIdField'/>

      3. Map the field value to the case record that will be created.           

    <input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Subject,subjectDetail;ChatCaseID__c,caseChatID;" />    
    <input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Subject,true;ChatCaseID__c,true" />    
    <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />
      4. Using JavaScript or visualforce assign a unique value to the CaseChatID field.               

This approach will prevent duplicate cases from being created as subsequent requests caused by a disconnection will have the same value as the first one. The chat functionality will not be affected.

*You can use any technique you wish to create a unique value for this field (JavaScript, Apex, etc.).





promote demote