Question: I Am trying to delete both ActivityHistory and FieldHistory archive but have run into the below errors: 

```
DML operation Delete not allowed on List<ActivityHistory>
DML requires SObject or SObject list type: List<FieldHistoryArchive>

```

I have enable 'Enable “Delete from Field History” and “Delete from Field History Archive” User Permissions' in the user interface settings and given the user account I am using permissions to edit both of these objects. 

It may be worth noting that I am able to access and delete ContactHistory and all other objects history.

Please see my code below:

```
            List<ActivityHistory> activityHistoryList = [Select Name, (Select Subject,ActivityType from ActivityHistories) from Contact where Id = :c.Id];
            delete activityHistoryList;

            List<FieldHistoryArchive> fha = [SELECT Id, FieldHistoryType, ParentId FROM 
            FieldHistoryArchive WHERE FieldHistoryType = 'Contact' AND ParentId = :c.Id]; 
            delete fha;

```

I have checked the API an release notes thouroughly and unfortunately can't find any documentation on this apart from some sample code on how to access the objects.

Answer: 
After enabling the system setting in User Interface, the User needs to be assigned a permission set also with that permission enabled (under System Permissions).
From this [stackexchange post](https://salesforce.stackexchange.com/questions/241594/can-we-delete-activityhistory-records-in-apex) 

[`ActivityHistory`](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_activityhistory.htm), as surfaced on the Contact and Account page layout in Salesforce Classic, is not exactly a real sObject; it is more like a view generated by the system into the Activity objects (Tasks and Events) which are in the past (Events) or closed (Tasks).

You can directly delete records in the `Task` and `Event` sObjects, which will remove the corresponding Activity History entries. 

You should be aware of [Activity archiving](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_guidelines_archive.htm#!) in your org. Archived Activities won't show up in normal queries, but [can be queried from the API](https://help.salesforce.com/articleView?id=000199524&type=1) with `queryAll()` or in SOQL with `ALL ROWS`, and can be deleted.