You need to sign in to do that
Don't have an account?
Developer Base
Apex testing class - creating records with a custom LastModifiedDate value
Trying to create data with a custom LastModifiedDate value for testing purpose. So far these things I've tried don't work:
Is there any other WORKING way how to set LastModifiedDate of a record?
- Using Test.loadData - although Salesforce provided us with information about setting custom value of LastModifiedDate, this does not seem to work even when following the tutorial. Link: https://help.salesforce.com/articleView?id=000332070&type=1&mode=1 (https://help.salesforce.com/articleView?id=000332070&type=1&mode=1)
- Using JSON.deserialize - also does not work - copied the sample code and tried the same method, it shows errors. Link: https://help.salesforce.com/articleView?id=000332070&type=1&mode=1 (https://help.salesforce.com/articleView?id=000332070&type=1&mode=1)
- Setting CratedDate through Test.setCreatedDate(recordId, createdDatetime) method - I hoped the LastModifiedBy field would have changed with it, it does not.
Is there any other WORKING way how to set LastModifiedDate of a record?
Happens on update. Does it work for you?