1

I have a list of Territory2 records. All of them are from the deepest level of my territory hierarchy. When I attempt to save some apex to Salesforce that would delete this list of records, I'm presented with the error...

DML operation Delete not allowed on List

I need to automate the deletion of these territories. What are my best options for doing that?

5

How do I mass delete Territory2 records in Apex?

You don't. You can use the REST or SOAP API, or an app like the Apex Data Loader, but a Territory isn't something you can automate directly in Apex Code. It's restricted because of the implications of doing this in something like a trigger, which could potentially cause sharing row locks when territories are quickly added or removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.