SandboxPostCopy Interface
To make your sandbox environment business ready, automate data manipulation or business logic tasks. Extend this interface and add methods to perform post-copy tasks, then specify the class during sandbox creation.
To make your sandbox environment business ready, automate data manipulation or business logic tasks. Extend this interface and add methods to perform post-copy tasks, then specify the class during sandbox creation.
Create an Apex class that implements SandboxPostCopy and specify the class here.
At sandbox creation, specify a single Apex class to perform the tasks. This class executes every time the sandbox is copied.
Sample code:
- global class SandboxPostRefreshHandler implements SandboxPostCopy {
- global void runApexClass( SandboxContext context ) {
- System.debug( context.organizationId() + ‘ – ‘ + context.sandboxId() + ‘ – ‘ + context.sandboxName() );
- }
- }
Test Class:
- @isTest
- private class SandboxPostRefreshHandlerTest {
- @isTest
- static void testMySandboxPrep() {
- Test.startTest();
- Test.testSandboxPostCopyScript( new SandboxPostRefreshHandler(), UserInfo.getOrganizationId(),
- UserInfo.getOrganizationId(), UserInfo.getOrganizationName() );
- Test.stopTest();
- }
- }