[SalesForce] How to set the Case origin to Chat from the PreChat form

the field Origin already exists and is a picklist with Chat as one of the options

Best Answer

Set the detail as a hidden input:

<input type="hidden" name="liveagent.prechat:caseOrigin" value="Chat" />

Map it:

<input type="hidden" 
       name="liveagent.prechat.findorcreate.map:Case"   
       value="Origin,caseOrigin;" />

Specify that you want it created:

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

If you want to show the Case when it is created make sure you set that as well:

<input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />

Note that if you are mapping multiple fields, the map and create inputs take a semi-colon separated list. For example, if you were mapping a caseSubject detail in addition to your caseOrigin detail, you'd have something like the following:

<input type="hidden" name="liveagent.prechat.findorcreate.map:Case" 
       value="Origin,caseOrigin;Subject,caseSubject;" />

<input type="hidden" name="liveagent.prechat.findorcreate.map.doCreate:Case" 
       value="Origin,true;Subject,true;" />


There isn't a ton of information out there on the Live Agent Pre-Chat API and Pre-Chat form, yet, as it is still relatively new. I recently wrote a very detailed article about the live agent pre-chat API.

Related Topic