Skip to content

Instantly share code, notes, and snippets.

@az-ak
Last active November 17, 2021 11:15
Show Gist options
  • Save az-ak/58f6043e886a069f0c65682f46349fe6 to your computer and use it in GitHub Desktop.
Save az-ak/58f6043e886a069f0c65682f46349fe6 to your computer and use it in GitHub Desktop.
Apex SandboxPostCopy example
global without sharing class SandboxPostCopyUpd implements SandboxPostCopy {
global void runApexClass(SandboxContext context) {
LIst<Contact> ConList = [SELECT ID FROM CONTACT];
for (Contact con : ConList) {
con.Email = '[email protected]';
}
update ConList;
}
}
@isTest
public class SandboxPostCopyUpd_test {
static testMethod void testSandboxPostCopyScript() {
Account acct = new Account (Name='Acme');
insert acct;
Contact con = new Contact (FirstName='Yamada',LastName='Taro',AccountId=acct.Id,Email='[email protected]');
insert con;
Test.testSandboxPostCopyScript(new SandboxPostCopyUpd(), '00D000000001111', '00D000000002222', 'sandboxName');
System.assertEquals(0,[SELECT count() FROM CONTACT WHERE Email !='[email protected]']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment