+ Start a Discussion
davidleckenbydavidleckenby 

Can you change the system date in a Sandbox environment for testing purposes?

We need to simulate running monthly scheduled batch apex jobs over multilple months/year to see mutiple records instances being recaluculed over time.

I can see that there are some comments from 2011 saying that this is not possible but just wanted to check in 2019? I am guessing not but just thought to ask.
Best Answer chosen by davidleckenby
Abdul KhatriAbdul Khatri
scheduled apex and batch apex jobs are mean't to kick of for bulk data specially batch apex. I am exactly not sure what your job is doing but the options provided keeping your need in perspective.

All Answers

Abdul KhatriAbdul Khatri
Option 1:
You can simulate that through a test class as Salesforce does allow change the createddate test classes. Please follow the link for details
http://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_apex_tests.htm#rn_apex_tests_setcreateddate

Option 2:
Import Test Data with the required createddate and createdby
https://success.scribesoft.com/s/article/Overriding-Create-Date-By-Fields-when-Migrating-Salesforce-Records
 
davidleckenbydavidleckenby
Thanks Abdul - this seems fine if you are creating new records where the creation date can be adjusted accordingly, but what if you need to kick off scheduled apex job that will impace multiple records? Is it still possible then?
Abdul KhatriAbdul Khatri
scheduled apex and batch apex jobs are mean't to kick of for bulk data specially batch apex. I am exactly not sure what your job is doing but the options provided keeping your need in perspective.
This was selected as the best answer
Abdul KhatriAbdul Khatri
Please let me know if I am able to help you out or not