Skip to main content
Paul Worlton (Celtic Bank) ha fatto una domanda in #Apex

I have a sandbox deploy script that works fine for setting environment variables but fails to create test data that I always need.  If I run the data insert methods manually, they work fine - but the deploy script seems to skip those methods. Is this an issue with calling static methods or does SandboxPostCopy intentionally block SOQL inserts?

The following is my main function:

// Main deploy script

global void runApexClass(SandboxContext context) {

// Set org to dev

Server__c srv = Server__c.getOrgDefaults();

srv.Environment__c = 'dev';

srv.Disable_Rules__c = true;

upsert srv;

createDummyAccountContact();

createTestLeads(10);

createTestLoans(4);

}

 

 
1 risposta
  1. 16 ott 2018, 15:24
    You need to do it like below 

     

    SandboxCreateBulkTestData cls = new SandboxCreateBulkTestData();

    Test.testSandboxPostCopyScript(cls, // the instantiated class that implements the SandboxPostCopy interface

    UserInfo.getOrganizationId(), // context org ID

    UserInfo.getOrganizationId(), // context SandboxID

    'sandbox');