• Etienne Coutant 6
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

I created a class in my PROD environment that implements SandboxPostCopy. My undersating is that when I create/refresh a sandbox and specify my class, the code in that class will be executed upon creating/refreshing the sandbox.

Here is the code I am using for the SandboxPostCopy class.
global class SandboxRefreshCutover implements SandboxPostCopy {

    global void runApexClass(SandboxContext context) {

        System.debug('Sandbox copy done. ' + context.organizationId() + ' ' + context.sandboxId() + context.sandboxName());
        
        //Replace the URL endpoint in a Customer Setting
        Integration_Endpoints__c integrationEndpoint = Integration_Endpoints__c.getValues('TEST');
        if(integrationEndpoint != null)
        {
            integrationEndpoint.URL__c = 'http://www.test.com';
            update integrationEndpoint;
        }
        else
        {
            integrationEndpoint = new Integration_Endpoints__c(Name = 'TEST', URL__c = 'http://www.test.com');
            insert integrationEndpoint;
        }
    }
}

Now, I tried to create a few developer sandboxes and everytime the code is not executed.
Am I missing something?

Thanks a lot in advance.
Etienne
Hi,

I created a class in my PROD environment that implements SandboxPostCopy. My undersating is that when I create/refresh a sandbox and specify my class, the code in that class will be executed upon creating/refreshing the sandbox.

Here is the code I am using for the SandboxPostCopy class.
global class SandboxRefreshCutover implements SandboxPostCopy {

    global void runApexClass(SandboxContext context) {

        System.debug('Sandbox copy done. ' + context.organizationId() + ' ' + context.sandboxId() + context.sandboxName());
        
        //Replace the URL endpoint in a Customer Setting
        Integration_Endpoints__c integrationEndpoint = Integration_Endpoints__c.getValues('TEST');
        if(integrationEndpoint != null)
        {
            integrationEndpoint.URL__c = 'http://www.test.com';
            update integrationEndpoint;
        }
        else
        {
            integrationEndpoint = new Integration_Endpoints__c(Name = 'TEST', URL__c = 'http://www.test.com');
            insert integrationEndpoint;
        }
    }
}

Now, I tried to create a few developer sandboxes and everytime the code is not executed.
Am I missing something?

Thanks a lot in advance.
Etienne