Search code examples
salesforceapex-code

How to fix "DML operation Delete not allowed on CaseShare" error in Salesforce?


I have a requirement which says the Case needs to be modified by any user. The state of the case can be modified or the owner can be changed by any user. Currently only the case owner can do this. To meet the requirement I have changed the Case Default Internal Access to Public Read/Write from Private. But I am getting error in case trigger where case sharing is being handled. Getting error "DML operation Delete not allowed on CaseShare" in the below line

Database.delete(sharesToDelete);

Please let me know where I am doing wrong.


Solution

  • Turns out Case sharing wasn't enabled.

    To do that, you will need to change organisation wide defaults (Security Controls>Sharing Settings), Case object 'Default External Access' to Private.