I am keen to delete some rows from the AccountHistory related list. This is because I initially did tracking history of too many fields and now the AccountHistory is overly long and this increases the time load of an account page.

Running an anon script via Workbench, I hit this error:

'DML operation DELETE not allowed on AccountHistory'.

I confirmed with Premier Support that AccountHistory (and it seems other History related lists) are locked.

Is there any way to get around this, so that unrequired rows can be deleted?



3 Answers 3


It is very risky, but apparently there is a known workaround: delete and recreate the affected Account.

Before you take any actions, back up all data. Make sure this includes all child data.

If you have a small number of records, you can clone them in execute anonymous (don't preserve id), delete the existing records, then insert the clones.

  • Good point about cloning the record! That'd be probably be easier than reinventing the wheel as in my answer. You'd probably have to be careful though with respect to objects referencing Account records, such as Contacts and anything custom? I'd imagine if you did this wrong, it'd be a really bad day for you.
    – Dan Jones
    Mar 17, 2016 at 15:47
  • You're right about that, this approach would require extreme care. I'll try to update with a little more detail when I get a chance.
    – Adrian Larson
    Mar 17, 2016 at 15:49
  • do not forget about triggers, flows and workflows on account object=)
    – kurunve
    Mar 17, 2016 at 16:02
  • @kurunve Yes very high risk. Disturbing that it's the only workaround I could find. I'd have serious reservations about it if I had to implement.
    – Adrian Larson
    Mar 17, 2016 at 16:17

Unfortunately, some objects you simply can't perform and kind of INSERT, UPDATE, DELETE or UNDELETE (a.k.a. DML) statements on.

You can make certain calls to the object, but can't actually do any custom DML on it.

describeSObjects(), getDeleted(), getUpdated(), query(), retrieve()

You can look here for more information.

As Adrian Larson has said in a comment, it's currently listed as an idea.

The only workaround I could see would be to create your own AccountHistory__c object and use a Trigger on the Account object to update the custom AccountHistory__c object whenever it's manipulated. You'd then have full DML control, although it'd be a lot of work reinventing the wheel.

Edit: If you're curious as to why there's a call for getDeleted() if you can't delete anything, that'll be to do with the objects behaviour. If you look here you'll see in the note that:

field history is retained for a maximum of 18 months.


It looks like this has now been enabled in the Salesforce Spring 18 Release.

A potential issue with changes not being available until the end of the transaction is addressed here.

You must log in to answer this question.

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