3

I'm looking for the object that holds field history changes for a custom object.

Related, I see that there is a ContactHistory object, but attempts to insert are rejected with

Field is not writable: ContactHistory.ContactId

I'd like to be able to insert history on a custom object, although this seems impossible.

This is a data migration issue, where changes to fields in one system need to be replicated for auditing purposes in the new Salesforce implementation.

I can understand that there are good reasons for disabling 'insert' permissions on history tracker objects, but it would be good if there was some way to temporarily enable it, in much the same way that I can request the temporary ability to change audit fields.

2
  • Try contacting Salesforce. The documentation says you can't edit the audit fields (LastModifiedBy, CreatedBy, etc.) but if you contact them they can make them editable for a short period of time. Maybe they might be able to do the same for the history object. I haven't heard of this happening, but I've also never asked.
    – Nick C
    Commented Feb 16, 2015 at 13:09
  • 2
    @NickCook I think this feature is only for audit fields not objects . Commented Feb 16, 2015 at 13:19

2 Answers 2

5

When you enable field history tracking for an object then the changes are stored in a special history table for that particular object.

The naming convention for these objects is:

[standardObjectName]History e.g. AccountHistory, ContactHistory etc.

[customObjectName]__History e.g. Car__History, Brand__History etc.

The objects are not writable and therefore you won't be able to upsert them via apex. Check these fields out using workbench.

enter image description here

3
  • 1
    Writes are not allowed for these objects I guess . Commented Feb 16, 2015 at 13:19
  • That is correct
    – Anup
    Commented Feb 16, 2015 at 13:32
  • Please mark this as resolved if it answers your question
    – Anup
    Commented Feb 16, 2015 at 13:50
4

The only way i see this can be achieved is using a Read Only Custom Object and storing the data in the custom object for audit purpose.

History Object doesn't allow you to insert records into them .

1
  • 2
    I don't like the idea of storing the history separately because it means there will be two histories, prior to Salesforce and post Salesforce. This would make reporting a mess. An alternate solution is to migrate as the data was generated. Ie upsert the field changes one at a time one each object.
    – powlo
    Commented Feb 16, 2015 at 15:54

You must log in to answer this question.

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