function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NaviNavi 

How to Pre populating fields (Contact, Case Origin etc) values in standard case new page using Live Agent without user entering values in prechat form?

Live Chat issue
We have live chat link set up inside of an iframe, the pre chat form also opens inside of an iframe.
We do not want the user to enter any values in the prechat (default ones being Name and email address as delivered by SF) – is there a method to pick up the user ID and auto populate the prechat and send the values across to the receiving side. If there is an existing case ID, the user will enter that on the prechat form and we expect to open up the same case number on the agent side.
We want to open a new case on the agent side if the user does not enter existing case # on the prechat form. As soon as the user clicks on submit on the prechat form, we expect to open a case on agent side with prepopulated values like contact, Case origin, Case record type for User name  in  standard case page using  User ID (though the user does not directly enter these on the prechat form). At a later stage, the case transcript will get added to this case once the chat completes.
bgm1234bgm1234
HI, 

Do u got any solution for the above . can you please help me. me to facing same issue
Vikash TiwaryVikash Tiwary
Hi Navi,

For prepopulating we do not have any predefined methods but you can do this either directly by binding the User object to the input fields or via javascript.

If there is an existing case ID, we can pass it on agent side so that this can be opened automatically on agen side when the chat is initiated.
// An auto query that searches Cases on agent side whose Id field matches the provided Id.
liveagent.addCustomDetail('Case Id', '{!inputCase.Id}').map('Case', 'Id', false, true);

I am not sure about if case on agent side can be opened with prepopulated values in standard case Edit page. But at later stage we can add the case transcript to the case when chat completes using trigger. Trigger will be written on insert of LiveChatTranscript record. When chat ends LiveChatTranscript record gets created and on create we can set its fields and then we can get its related case and copy the body of LiveChatTranscript record to the related cases. The field values of LiveChatTranscript object can be set as shown below.

// Saves the custom detail to a custom field on LiveChatTranscript at the end of a chat
   liveagent.addCustomDetail('CaseId', '{!inputCase.Id}').saveToTranscript('CaseId');
   
// Saves the Account and Contact Id to a custom field on LiveChatTranscript at the end of a chat           
   liveagent.addCustomDetail('ContactId', '{!userObj.ContactId}').saveToTranscript('ContactId');
   liveagent.addCustomDetail('AccountId', '{!inputCase.AccountId}').saveToTranscript('AccountId');

Hope this helps! If any further questions please let me know.

Thanks 
Vikash