Post Sandbox copy apex class not executed or picking an older class
Last updated 2019-09-07 ·Reference W-4049444 ·Reported By 15 users
Summary
When you choose an apex class(which implements "SandboxPostCopy" interface) to execute after Sandbox copy while creating or refreshing the Sandbox, this will work as expected and the apex class is executed post copy.
In the next refresh cycle when you are refreshing this Sandbox again and this time if you have chosen a different apex class to be executed after copy you might see an issue where it still picks the older apex class or if the older apex class is deleted from the org it will not run the apex class post Sandbox copy.
Repro
- Create two simple classes which implements "SandboxPostCopy" interface as below.
global class Class1 implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
System.debug('Hello Tester Pester ' + context.organizationId()
+ ' ' + context.sandboxId() + context.sandboxName());
}
}
global class Class2 implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
System.debug('Hello Tester Pester ' + context.organizationId()
+ ' ' + context.sandboxId() + context.sandboxName());
}
}
- Create or refresh a Sandbox by choosing "Class1" as post copy apex class.
- Here you will observe two scenarios.
Scenario 1:
- Once the refresh life cycle is complete, now try to refresh the Sandbox again and now choose Class2 as post copy apex class.
- Once the refresh is completed after following the above steps and open the Sandbox detail page from Production org you will observe that in the Apex class section it is still referring to older class "Class1"
Scenario 2:
- Delete the previous class "Class1" and try to refresh the Sandbox by choosing "Class2" as post copy apex class.
- Once the refresh is completed, open the Sandbox detail page from Production org you will observe that in the Apex class section it is blank and the apex class is not executed after Sandbox refresh
Workaround
- As of now there is no workaround which can be followed at your side till the bug is fixed.
- If you encounter any scenario as mentioned above, please log a case with Salesforce support and provide them with this known issue link. We can help fix the issue for the org by setting the post copy apex class to appropriate apex class Id.
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.