Run Script After Sandbox Creation and Refresh

This feature is to make your sandbox environment business ready, automate data manipulation or business logic tasks.

At sandbox creation, specify a single Apex class to perform the tasks. This class executes every time the sandbox is refreshed/copied.
Lightning interface of sandbox post-copy script specification
Create an Apex class that implements SandboxPostCopy and specify the class here. For example, the following Apex class simply reports the three contexts available in SandboxPostCopy: your organization ID, sandbox ID, and sandbox name:
global class HelloWorld implements SandboxPostCopy {
  global void runApexClass(SandboxContext context) 
  {   
      System.debug(context.organizationId());
      System.debug(context.sandboxId());
      System.debug(context.sandboxName());
   }
}
Note: This feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. It can’t be guaranteed general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Advertisements

2 Replies to “Run Script After Sandbox Creation and Refresh”

  1. Hi,

    Now that this feature is GA, do you have information on what this class can do? What are its limits?

    Release notes has very small information on this.

    Thanks, Manju

    Like

    1. Hi Manju. Salesforce hasn’t mentioned any limitations on this too. So, I’m sure it can do the basic stuff at least like:

      – Object data insertions (which is the most important feature here, to have some data in our sandboxes immediately after refresh).

      – Any static constants records

      – Configure scheduled apex jobs

      Will keep you posted if I hear of any specific limitations.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s