I have a page where I know the Id of the case I want create a new chat session about. The desired goal is to have the case open for the agent and link the transcript to the existing case. I'm trying to use findOrCreate with Id, but it isn't working. I'm hoping I just got my syntax wrong.

liveagent.init("https://d.la2-c2cs-iad.salesforceliveagent.com/chat", "572A00000000000", "00D0U0000000000");
  • This question seems quite closely related to your previous one. Might be best to just edit this information in there? I am interested to see if any answers pop up though.
    – Adrian Larson
    Oct 12, 2017 at 18:23
  • Yeah, I'm going to edit the previous one as they are kind of different. I think I've got the answer to that one. Oct 12, 2017 at 18:27
  • Ah, yeah now it makes sense they're separate questions. Thanks.
    – Adrian Larson
    Oct 12, 2017 at 18:31

3 Answers 3


Turns out I misread the Deployment API documentation. I thought you could just shove in values directly in findOrCreate, but instead you have to first addCustomDetail and then use the name you used there in the findOrCreate. In the code below, {!CaseId} is referencing a variable in my controller.

liveagent.addCustomDetail("CaseId", '{!CaseId}');
liveagent.init("{!LADomain}", "{!LADeployId}", "{!OrgId}");

Here's the code I use to do a findorcreate doFind with an ID:

var contactEmail = document.getElementById('email').value;
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.PreChatController.getcontact}', contactEmail, function(result, event){
    if (event.status) {
        document.getElementById('contactId').setAttribute('value', result.Id);

and then

<input type="hidden" name="liveagent.prechat:Contact ID" id="contactId" />
<input type="hidden" name="liveagent.prechat.findorcreate.map:Contact" value="Id,Contact ID" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doFind:Contact" value="Id,true" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.isExactMatch:Contact" value="Id,true" />

Does that help?

  • 1
    I don't think I want to use the prechat API - I'm trying to avoid having a prechat page all together. The deployment API has similar methods, but the syntax is different. Oct 13, 2017 at 12:50

May be a bit old question.

We achieved it inside VF page without using Pre-chat page at all . It can be done in 2 ways.

  1. Leverage deployment APi and addCustomDetail("CaseId", '{!CaseId}')

    <script type='text/javascript'>
         liveagent.addCustomDetail("CaseId", '{!caseId}');
     <!-- Chat Deployment Code to initialize, replace with your org's values -->
     liveagent.init('https://d.***.salesforceliveagent.com/chat', '572530000***', '00D530000***');
  2. Update embedded service prechat form details to map existing data inside initESW function

      embedded_svc.settings.extraPrechatFormDetails = [{
             embedded_svc.settings.extraPrechatInfo = [{
                 "entityFieldMaps": [{

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .