You need to sign in to do that
Don't have an account?
Etienne Coutant 6
SandboxPostCopy not working for us
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.
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
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
You can get mored detail over here https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_System_SandboxPostCopy.htm
Thanks
Sandeep Singhal
Thanks. I know it should work, but for some reason the values are not updated in the target sandbox as it should be... Seems like the code is not executed.
Etienne
The code that exist in runApexClass does work when I call it from unit test and apex anonymous.
Is there anyone who was able to create a class that implements SandboxPostCopy and have it executed correctly upon sandbox refresh???
I cannot create a Case for Salesforce as it requires Premium Support...
Best,
Etienne
"R&D team has identified this issue as a bug and are working on it to fix the same"
Hello Emil & Tony,
I think the problem is the method should run in @future context. So in your runApexClass method call another method updatecustomsetting()
and write the logic inside and this should work.
I have a number of methods listed as that and none of them are getting run.
Would be curious to know if ANYONE has got this to work?
Tony.
I am curious to know, as we are in 2020, is this resolved?
Becouse i am trying to implement this.
Any workaround that has been provided for this issue.
I will take that workaround in consideration while implementing my logic.