I am creating a test class and the scenario I am testing requires an older date for the created date. I know CreatedDate is an audit field and I can't write to it. Is there a workaround I could use for writing my test class?


  • Kenn, I have not found any workaround for this. Audit fields are available to write only at the time of initial data import that too after contacting Salesforce.
    – Devendra
    Commented Mar 27, 2013 at 18:08

1 Answer 1


I dont think we can write CreatedDate field as it comes under System Audit Field.

  • Hi Davendra, I was looking for a working around tips or tricks in situations where u have to have an older date for created date in a unit test. Audit fields can't be written to for sure unless salesforce is contacted.
    – Kenn K
    Commented Mar 26, 2013 at 17:12

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