[SalesForce] Live Agent, What is the correct syntax to create a case from the pre-chat form

I am trying to create a case once the visitor submits the pre-chat form but is not working, the record is not created. I managed to get it working using the deployment API but not from the pre-chat form. My guess is that I am not using the correct syntax but there aren't any good examples in the documentation for this.

This is a snippet from my pre-chat form. I want to populate the origin field with the value "Chat", this is obviously just for testing purposes, I want to populate multiple fields and show the case to the agent when he/she accepts the chat.

<input type="hidden" name="liveagent.prechat:origin" value="Chat"/>
<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="origin,liveagent.prechat:origin;" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:case" value="true"/>

Thanks

Best Answer

Example: Create a case with the value "Chat" as Origin.

<input type='hidden' name='liveagent.prechat:caseorigin' value='Chat'/>
<input type='hidden' name='liveagent.prechat:caseContactId' value='{!$User.ContactId}'/>

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" value="Origin,caseorigin;ContactId,caseContactId;" />
<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" value="Origin,true;ContactId,true;" />
<input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="Case" />
<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

UPDATE: I discovered the field names are case-sensitive.

UPDATE: I have updated the example to show how to add multiple fields.

Related Topic