2
public static void changeChatCapacity() {
        PresenceUserConfig maxCapacity = [
            SELECT Id, Capacity, OptionsIsDeclineEnabled
            FROM PresenceUserConfig
            WHERE DeveloperName = 'AgentChat'
        ];
        maxCapacity.OptionsIsDeclineEnabled = true;
        try {
            update maxCapacity;
        } catch (DmlException e) {
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
    }

This code returns the error:

DML operation Update not allowed on PresenceUserConfig

Salesforce documentation sites that DML operations is available on this object. Does anyone know why this happens?

1
  • have you checked that you have update permission on this object?
    – Patlatus
    Commented Oct 1, 2021 at 13:56

1 Answer 1

2

The SOAP/REST/Tooling/etc documentation tells you if you can perform a given operation in that API. Apex is not allowed to perform DML on some types of objects that are otherwise createable/updateable in an API. These objects are usually restricted because the data can't be properly completed atomically within an Apex transaction or could otherwise cause "weird" behavior in the transaction. Unfortunately, the documentation doesn't explain why Apex cannot perform a particular operation, so all we usually have is the error message from the runtime itself. As such, it appears you will need to use a REST API call from Apex in order to achieve your goals.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .