Skip to content

Instantly share code, notes, and snippets.

@jkentjnr
Created January 30, 2025 02:22
Show Gist options
  • Save jkentjnr/6bf40f016cae4027a556563164690166 to your computer and use it in GitHub Desktop.
Save jkentjnr/6bf40f016cae4027a556563164690166 to your computer and use it in GitHub Desktop.
Delete NPC Data from Environment
String prefix = 'cte';
// Get gift transactions
List<GiftTransaction> lstGT = [SELECT Id FROM GiftTransaction WHERE md_npc_pack__Platform_Key__c LIKE :prefix + '%'];
System.Debug(lstGT);
// Delete installments associated with Gift Transasctions
List<cpm__Installment__c> lstI = [SELECT Id FROM cpm__Installment__c WHERE fdff__GiftTransaction__c IN :lstGT];
System.Debug(lstI);
if (lstI.size() > 0) delete lstI;
// Delete gift transactions
delete lstGT;
// --------------------------
// Delete gift commitments
List<GiftCommitment> lstGC = [SELECT Id FROM GiftCommitment WHERE md_npc_pack__Platform_Key__c LIKE :prefix + '%'];
System.Debug(lstGC);
delete lstGC;
// --------------------------
// Delete campaigns
List<Campaign> lstC = [SELECT Id FROM Campaign WHERE movedata__Platform_Key__c LIKE :prefix + '%'];
System.Debug(lstC);
delete lstC;
// --------------------------
// Get Accounts by Key
List<Account> lstA = [
SELECT Id FROM Account WHERE Id IN (SELECT movedata__Account__c FROM movedata__Account_Platform_Key__c WHERE movedata__Platform_Key__c LIKE :prefix + '%')
];
System.Debug(lstA);
delete lstA;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment