0

When attempting to use REST API to delete multiple object records like so:

h t t p s://org.my.salesforce.com/services/data/v42.0/composite/sobjects?ids=0010x000000000,a1r0x000000001,a1m0x000000002,a1w0x000000003,a1r0x000000004,a1w0x000000005,a1m0x000000006&allOrNone=true

I'm getting errors that look like this:

"success": false, "errors": [ { "statusCode": "DELETE_FAILED", "message": "Your attempt to delete Test Loan kvNrH could not be completed because it is associated with the following opportunity history.: OH-00549884\n", "fields": [] }

However, the OH-00549884 that the error is complaining about is also in the list of IDs to delete in the URL.

I found that if I have the allOrNone set to false I can run it twice and everything is deleted (however, not a very elegant solution). So I'm trying to do this all in one go. Has anyone had to overcome this issue, or have an approach for overcoming this?

1

You are attempting to delete records belonging to multiple Sobject types.

The Salesforce Lightning REST Documentation to Delete Multiple Records with Fewer Round-Trips explains the following Usage Guidelines

  • The DeleteResult objects are returned in the order in which the IDs of the deleted objects were specified.
  • You can't delete records for multiple object types in one call when one of those types is related to a feature in the Salesforce Setup area.

I suspect that point #2 is what is causing an issue in your case.

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.