2

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.findOrCreate('Case').map('Id','5000U000000V1FGQA0',true,false,false).saveToTranscript('CaseId').showOnCreate();
liveagent.init("https://d.la2-c2cs-iad.salesforceliveagent.com/chat", "572A00000000000", "00D0U0000000000");
3
  • 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 '17 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. – Daniel Hoechst Oct 12 '17 at 18:27
  • Ah, yeah now it makes sense they're separate questions. Thanks. – Adrian Larson Oct 12 '17 at 18:31
2

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.findOrCreate('Case').map('Id','CaseId',true,true,false).saveToTranscript('CaseId').showOnCreate();
liveagent.init("{!LADomain}", "{!LADeployId}", "{!OrgId}");
0

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
  • 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. – Daniel Hoechst Oct 13 '17 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.