How to delete Chat Session Records in Salesforce?

How to delete Chat Session Records in Salesforce?

Chat Session records are stored in LiveAgentSession entity.

Following Sample code can be used to delete the Chat Session records permanently(hard delete).

Sample Code:

List < LiveAgentSession > listLiveAgentSessions = [ SELECT Id FROM LiveAgentSession ];
if ( listLiveAgentSessions.size() > 0 ) {
  delete listLiveAgentSessions;
  Database.emptyRecycleBin( listLiveAgentSessions );
} 

SOQL:

SELECT Id, AgentId, LoginTime, LogoutTime
FROM LiveAgentSession

The above SOQL can be used to Query Chat Session(LiveAgentSession) records.

Leave a Reply