Purging the Org
Purging data from a Salesforce org involves permanently deleting or erasing records and associated data from your Salesforce instance. It's essential to exercise caution and follow best practices to ensure that you're removing the right data and adhering to Salesforce data governance and compliance guidelines.
Here are the steps to purge data from a Salesforce org:
1. Understand Data Deletion
Before purging data, understand the implications and the irreversibility of this action. Purged data cannot be recovered.
2. Backup Data
It's highly recommended to create a backup of the data you intend to purge. Salesforce provides export and backup tools, such as Data Export, to create backups of your data.
3. Identify Data to Purge
Determine the records and data you want to purge. This could include old, obsolete, or test records.
4. Delete Records
Delete records using Salesforce's native data management tools. Depending on the amount of data to be deleted, you can choose the appropriate method:
>Manually Delete Records:
– Navigate to the relevant object in Salesforce.
– Select the records you want to delete and click "Delete."
>Using Data Loader:
– Use Data Loader to perform bulk deletions based on specific criteria.
>Using Apex:
– Write an Apex script to delete records based on your criteria.
5. Empty Recycle Bin
Deleted records go into the Salesforce Recycle Bin. To permanently remove them:
– Navigate to Setup > Recycle Bin.
– Select the records you want to permanently delete and click "Empty."
6. Verify and Monitor
Verify that the intended records have been deleted and ensure that no critical data was inadvertently removed. Monitor the system to confirm that the data is no longer present.
How to run anonymous apex scripts:
To execute Apex code in the anonymous window in Salesforce, you can use the Developer Console or Workbench. Here are steps to execute Apex in the anonymous window using the Developer Console:
1. Open the Developer Console
– Log in to your Salesforce organization.
– Navigate to the App Launcher (grid icon) and select "Developer Console."
2. Access the Anonymous Apex Window
– In the Developer Console, select the "Debug" menu and click "Open Execute Anonymous Window."
3. Write and Execute the Apex Code
– In the "Enter Apex Code" window that appears, enter the Apex code you want to execute.
– For example:
4. Execute the Code
– Click the "Execute" button to run the code.
The Apex code will be executed, and the results will be displayed in the "Logs" tab at the bottom of the Developer Console.
Alternatively, you can use Salesforce Workbench, a powerful web-based tool, to execute anonymous Apex:
1. Access Salesforce Workbench
– Go to https://workbench.developerforce.com/.
– Log in with your Salesforce credentials.
2. Select "Utilities" > "Apex Execute"
– In Workbench, navigate to the "Utilities" menu and select "Apex Execute."
3. Write and Execute the Apex Code
– Write your Apex code in the provided text area.
4. Execute the Code
– Click the "Execute" button to run the code.
The results and any debug logs will be displayed below the text area.
Ensure you have the necessary permissions to execute Apex code in an anonymous window.
Data Deletion from Aedon Objects
Use the Apex script below to delete the data from Aedon application using the apex script below by running it in anonymous apex window.
|
Tip
Aedon supports multi company environment and these queries below are not specific to a company, if you need to delete data in a specific company, please include the company ID in where clause in all the queries below. |
Step 1
Run the below queries to update the VAT_Return_Submitted__c and Posting_Status__c fields before deleting the transactions:
//Updating VAT_Period_Config__c VAT_Return_Submitted__c field to false
List ObjVatList = [SELECT Id, aed0n7__VAT_Return_Submitted__c FROM aed0n7__VAT_Period_Config__c LIMIT 9000];
for(aed0n7__VAT_Period_Config__c VatPeriod :ObjVatList)
update ObjVatList;
//Updating Scheduled_Journals_Header__c Posting_Status__c field to Draft
List ObjschJournalList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Journals_Header__c LIMIT 9000];
for(aed0n7__Scheduled_Journals_Header__c SchJournal :ObjschJournalList)
update ObjschJournalList;
//Updating Expense_Scheduled_Journals_Header__c Posting_Status__c field to Draft
List ObjExpSchJournalList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Expense_Scheduled_Journals_Header__c LIMIT 9000];
for(aed0n7__Expense_Scheduled_Journals_Header__c ExpSchJournal :ObjExpSchJournalList)
update ObjExpSchJournalList;
//Updating Recurring_Sales_Invoice_Header__c Posting_Status__c field to Draft
List ObjRecSIList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Recurring_Sales_Invoice_Header__c LIMIT 9000];
for(aed0n7__Recurring_Sales_Invoice_Header__c RecSI :ObjRecSIList)
update ObjRecSIList;
//Updating Scheduled_Sales_Invoice_Header__c Posting_Status__c field to Draft
List ObjSchRecSIList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Sales_Invoice_Header__c LIMIT 9000];
for(aed0n7__Scheduled_Sales_Invoice_Header__c SchRecSI :ObjSchRecSIList)
update ObjSchRecSIList;
//Updating Recurring_Purchase_Invoice__c Posting_Status__c field to Draft
List ObjRecPIList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Recurring_Purchase_Invoice__c LIMIT 9000];
for(aed0n7__Recurring_Purchase_Invoice__c RecPI :ObjRecPIList)
update ObjRecPIList;
//Updating Scheduled_Purchase_Invoice_Header__c Posting_Status__c field to Draft
List ObjSchRecPIList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Purchase_Invoice_Header__c LIMIT 9000];
for(aed0n7__Scheduled_Purchase_Invoice_Header__c SchRecPI :ObjSchRecPIList)
update ObjSchRecPIList;
//Updating Scheduled_Sales_Payments__c Posting_Status__c field to Draft
List ObjSchSalesPmtList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Sales_Payments__c LIMIT 9000];
for(aed0n7__Scheduled_Sales_Payments__c SchsalesPmt :ObjSchSalesPmtList)
update ObjSchSalesPmtList;
//Updating Scheduled_Purchase_Payments__c Posting_Status__c field to Draft
List ObjSchPurchasePmtList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Purchase_Payments__c LIMIT 9000];
for(aed0n7__Scheduled_Purchase_Payments__c SchPurchasePmt :ObjSchPurchasePmtList)
update ObjSchPurchasePmtList;
//Updating Recurring_Journal_Header__c Posting_Status__c field to Draft
List ObjRecJournalList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Recurring_Journal_Header__c LIMIT 9000];
for(aed0n7__Recurring_Journal_Header__c RecJournal :ObjRecJournalList)
update ObjRecJournalList;
//Updating Scheduled_Recurring_Journal_Header__c Posting_Status__c field to Draft
List ObjSchRecJournalList = [SELECT Id, aed0n7__Posting_Status__c FROM aed0n7__Scheduled_Recurring_Journal_Header__c LIMIT 9000];
for(aed0n7__Scheduled_Recurring_Journal_Header__c SchRecJournal :ObjSchRecJournalList)
update ObjSchRecJournalList;
Step 2
Execute the below queries one by one:
|
Tip
If the Record Count is more that 9000, execute the query multiple times until the data is deleted completely. |
delete [SELECT Id from aed0n7__Ledger_Entry__c limit 9000];
delete [SELECT Id from aed0n7__Sales_Allocation__c limit 9000 ];
delete [SELECT Id from aed0n7__Payment_History__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Refund_Header__c limit 9000];
delete [SELECT Id from aed0n7__Sales_Credit_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_POA_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Payment_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Gain_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Loss_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Invoice_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Sales_Order_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Proforma_Sales_Invoice_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Allocation__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Refund_Header__c limit 9000];
delete [SELECT Id from aed0n7__Purchase_Credit_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_POA_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Payment_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Gain_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Loss_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Invoice_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Purchase_Order_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Manual_Journal_Header__c limit 9000 ];
delete [SELECT Id from aed0n7__Bank_Gain__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Loss__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Payment_Header__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Receipt_Header__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Revalue__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Transfer__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Nominal_Transactions__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Reconciliation_History__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Statement__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Feed__c limit 9000 ];
Delete [SELECT Id from aed0n7__Bank_Account__c limit 9000 ];
Delete [SELECT Id from aed0n7__VAT_Return__c limit 9000 ];
Delete [SELECT Id from aed0n7__VAT_Period_Config__c limit 9000 ];
Delete [SELECT Id from aed0n7__Accrual_Transactions__c limit 9000 ];
Delete [SELECT Id from aed0n7__Prorated_Cash_Transaction__c limit 9000 ];
Delete [SELECT Id from aed0n7__VAT_Report_Batch__c limit 9000 ];
Delete [SELECT Id from aed0n7__AR_Batch_Job__c limit 9000 ];
Delete [SELECT Id from aed0n7__Aged_Debtors__c limit 9000 ];
Delete [SELECT Id from aed0n7__Balance_Sheet_Report_Detail__c limit 9000];
Delete [SELECT Id from aed0n7__Balance_Sheet_Report_Job__c limit 9000];
Delete [SELECT Id from aed0n7__P_L_Monthly_Report_Job__c limit 9000];
Delete [SELECT Id from aed0n7__Profit_Loss_Monthly__c limit 9000];
Delete [SELECT Id from aed0n7__P_L_Cumulative_Report_Job__c limit 9000];
Delete [SELECT Id from aed0n7__Profit_Loss_Cumulative__c limit 9000];
Delete [SELECT Id from aed0n7__AP_Batch_Job__c limit 9000];
Delete [SELECT Id from aed0n7__Aged_Creditors__c limit 9000];
Delete [SELECT Id from aed0n7__Purchase_Ledger__c limit 9000];
Delete [SELECT Id from aed0n7__Sales_Ledger__c limit 9000];
Delete [SELECT Id from aed0n7__SP_Failure_Header__c limit 9000];
Delete [SELECT Id from aed0n7__PP_Failure_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Sales_Unallocation__c limit 9000];
Delete [SELECT Id from aed0n7__Purchase_Unallocation__c limit 9000];
Delete [SELECT Id from aed0n7__Budget_Journal_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Bulk_Post_Master__c limit 9000];
Delete [SELECT Id from aed0n7__Bulk_Pay_Master__c limit 9000];
Delete [SELECT Id from aed0n7__Revenue_Recognition_Schedule__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Journals_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Recurring_Sales_Invoice_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Sales_Invoice_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Sales_Payments__c limit 9000];
Delete [SELECT Id from aed0n7__Sales_Payment_Schedule__c limit 9000];
Delete [SELECT Id from aed0n7__Expense_Recognition_Schedule__c limit 9000];
Delete [SELECT Id from aed0n7__Expense_Scheduled_Journals_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Recurring_Purchase_Invoice__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Purchase_Invoice_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Purchase_Payment_Schedule__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Purchase_Payments__c limit 9000];
Delete [SELECT Id from aed0n7__Scheduled_Recurring_Journal_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Recurring_Journal_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Trial_Balance_Report_Details__c limit 9000];
Delete [SELECT Id from aed0n7__Trial_Balance_Report_Job__c limit 9000];
Delete [SELECT Id from aed0n7__Bank_Matching_Rule__c limit 9000];
Delete [SELECT Id from aed0n7__Match_Bank_Receipt_Header__c limit 9000];
Delete [SELECT Id from aed0n7__Match_Bank_Payment_Header__c limit 9000];
Step 3 – Updating Account Balance__c field to 0.00 for all Accounts
List ObjAccList = [SELECT Id, aed0n7__Balance__c FROM Account LIMIT 9000];
for(Account accList :ObjAccList)
update ObjAccList;




















