You need to sign in to do that
Don't have an account?
Aaron Winters 24
SandboxPostCopy Interface not working
I'm an administrator for two orgs (one on na2 and one on na27) and I haven't been able to get a class based on the new SandboxPostCopy interface to execute on sandbox refresh for either org. At this point I am trying to see if I can even get a simple script to execute on refresh. The class, test class and refresh steps are below. Am I missing something?
SandboxPostCopy class:
This is the test class:
This is what I enter in the Create Sandbox step of the refresh process:
Thanks very much in advance!
Aaron
SandboxPostCopy class:
global class HelloSandbox implements SandboxPostCopy { global void runApexClass(SandboxContext context) { Account a = new Account(Name='Acme'); insert a; } }This code executes fine with Execute Anonymous.
This is the test class:
@isTest class HelloSandboxTest{ @isTest static void testSandboxPostCopyScript() { HelloSandbox apexclass = new HelloSandbox(); Test.testSandboxPostCopyScript(apexclass, UserInfo.getOrganizationId(), UserInfo.getOrganizationId(), 'dev'); System.assertEquals(1,1,'Test something'); } }Where the development sandbox is named "dev". This covers 100% of code in the related class.
This is what I enter in the Create Sandbox step of the refresh process:
Thanks very much in advance!
Aaron
Hello Aaron,
I think the problem is the method should run in @future context. So in your runApexClass method call another method createAccount()
and write the logic inside and this should work.