1

In an Org I am trying to find the metadata of an object with api - Charts__History(Yes, with no __c). I could not find it in Salesforce Org UI so I used workbench to investigate.

I can run the query editor and I get a result. I am trying to add some value for this object as it has been used in a test class. Below is what I get from query editor:

enter image description here

From WorkBench:

enter image description here

enter image description here

enter image description here

What could be this metadata and what can I try to create a record related to this.

1 Answer 1

3

When you enable Field History Tracking for a Custom Object, a new object will be available to track these changes. This new object will have the same API Name as your custom object, except it will have the __history suffix instead of __c. You will need to change a tracked field and commit the update in order for such changes to show up in your database.

See also: What are the object and field name suffixes that Salesforce uses? Such as __c and __x

5
  • You might need to use SeeAllData for the tracked __history record to appear during your test. I'll have to double check.
    – Adrian Larson
    Commented Nov 21, 2017 at 19:19
  • 1
    Creating or modifying data in a test class or method with @seeAllData does not create field tracking history (just tried on cs14). See this question for a discussion on how to create field tracking records in test classes (hint: its a nightmare). Commented Nov 21, 2017 at 19:25
  • Well at least with that annotation you can query existing records without needing to create them yourself.
    – Adrian Larson
    Commented Nov 21, 2017 at 19:27
  • I create a record and changed the field that is been tracked. Used a query to retrieve __History but did not see any record returned. I tried with seeAllData as well. I might be missing something?
    – SfdcBat
    Commented Nov 21, 2017 at 19:33
  • As per my above comment, modifying records in a test context will not create a field tracking history record. You can vote on an idea to change this behavior here. If you have a specific use case where you need to cover some section of code which relies on existing field history records, I'd suggest asking a new question instead of trying to change the scope of an existing question. Commented Nov 21, 2017 at 19:38

You must log in to answer this question.

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