function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AdrianCCAdrianCC 

Debugging Sandbox refresh script

Hi guys,

I got a problem with a script class that I'm using for refreshing dev sandboxes from production.
Class is based off https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm?edition=&impact= and it does a bunch of dml operations: 2 updates on users(disable non-admins and fix the '@example.com' for admins), 2 inserts with configuration records (for some custom objects that we are using) and another 5 inserts with normal test data (accounts, opps etc). It also sends a status email with details about operation (it should send it but it doesn't, I guess cause of the Email Deliverability setting on the Sandbox).

I start the refresh with the class selected and autoactivation and I get the email with the ""SanboxAfterRefreshHandler" apex class run finished. Check debug logs for stack trace". Very nice and quaint. 
Problem is only the user dml operations finish successfully. 

1. How can I see why the rest isn't working when refreshing a sandbox?? (they work fine when testing with Open Execute Anonymous Window)
2. Where are the debug logs saved? Are they in production? Setup >Monitoring > Debug logs?
3. This begs the question: is the class executed at Production level? or at the refreshed sandbox level??
4. Can I send an email at the end with debug details? Is this affected by the Email Deliveratbility from the sandbox?

PS:
I'm testing right now by hand (deploy partially commented class to Prod, run the sandbox refresh with the class, check in the sandbox if it did what it should...) but this process is not efficient - it take a full day.
Also, the user deactivation dml takes a lot of time when running the test class for it, 10 minutes or something, just smth that I observed

Thank you and
Happy Monday!
Adrian
 
AdrianCCAdrianCC
Any little help or idea is highly appreciated!

Ty,
Adrian