0

I am preparing the testSetup() and I need to set the LastModifiedDate of the record one month earlier. Is that possible somehow?

Field is not writeable: Contact.LastModifiedDate

1 Answer 1

1

To create testdata with lastModifiedDate in the past follow the below link

https://help.salesforce.com/articleView?id=000332070&type=1&mode=1

OR

Step 1- Create CSV File for your sobject

name createdDate lastmodifiedDate

Test1 2000-01-01T00:00:00Z 2001-01-01T00:00:00Z

Test2 2000-01-02T00:00:00Z 2001-01-02T00:00:00Z

Step 2 - save as Static Resource (named here as recordsWithLastModDateInPast)

Step 3 - Code test method

@istest
private static void testLastModDateInPast () {

    TestObj__c[] recordList = test.loadData(TestObj__c.sObjectType,'recordsWithLastModDateInPast');
    system.debug(loggingLevel.INFO,recordList);
}
2
  • Hey Chetan, can you add some context and code snippet explaining? It has often seen that links die and the answer becomes irrelevant then/ Sep 2, 2019 at 10:01
  • Hi Pranay, I have added code snippet for reference. Sep 2, 2019 at 10:14

You must log in to answer this question.

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