Live Chat stop working after Summer '20 release

Published in Troubleshooting Exceptions

Are you using LiveChatButton object in your apex classes? If yes, you can be affected.

Wanna track the issue?
Navigate to the Known Issue: LiveChatButton entity is not accessible to guest user or portal user and clicks the This Issue Affects Me button to add yourself to the Reported By count. You will receive an email notification when the issue has been resolved.

What's wrong?
After Summer '20 release guest and community users loss access to the LiveChatButton object. If this object used in the Apex classes, double-check that functional using different users. The issue can affect the Live Chat functional in case if you use custom Visualforce Pages in Chat Buttons. Please note that affected only apex class that uses with sharing keyword. When you found that something goes wrong check debug logs if there is the next error:

System.QueryException: sObject type 'LiveChatButton' is not supported.

The exception can be caused by the next SOQL:
LiveChatButton liveChatButton = [
    SELECT Id 
    FROM LiveChatButton 
    WHERE DeveloperName = 'XXX'
];


Is there currently a workaround in place?
One possible workaround is using the without sharing keyword on a class. But more safely would be to create the inner class with the without sharing keyword to query LiveChatButton object.
/* skipped code */
LiveChatButtonPermissionWorkaround liveChatUtil = new LiveChatButtonPermissionWorkaround();
LiveChatButton liveChatButton = liveChatUtil.query('XXX');
/* skipped code */

public without sharing class LiveChatPermissionWorkaround {
    public LiveChatButton query(String developerName) {
        return [
            SELECT Id 
            FROM LiveChatButton 
            WHERE DeveloperName =: developerName
        ];
    }
}

Useful links:
Tagged under: Summer'20 Live Chat

Comments powered by CComment