How to recover deleted apex class in salesforce

image

you can retrieve the deleted class or trigger id from workbench using the following SOQL query: Select Id,Name from ApexTrigger where status=’deleted’ or name=’classname’

Unfortunately, once an Apex class or trigger is deleted, it is not possible to recover it. Developers are encouraged to keep up-to-date backups of any Apex code written, as Salesforce is unable to restore Apex code once it has been deleted.

Full
Answer

How to restore a deleted class in Salesforce?

Enter this code (or something like it), replacing ‘DeletedClass’ with the name of the class you want to restore: System.Debug (deletedClass.id); Run it and find the id of the class in the Debug output in the ‘Execute Anonymous’ window Append the id to the base URL of your Salesforce environment in your browser e.g. :

How to recover deleted apex triggers/classes/VF pages?

Why is there no way to recover deleted Apex Triggers/Classes/VF Pages? Currently, it is not possible to recover a deleted triggers or classes. However, you can retrieve the deleted class or trigger id from workbench using the following SOQL query:

How to find the class name of a deleted apextrigger?

Select Id,Name from ApexTrigger where status=’deleted’ or name=’classname’ After getting the Id, you may try to browse to the following URL: https://<instance>.salesforce.com/<trigger-or-class-id> to see if the code of the trigger/class is still accessible.

How to recover deleted records from the Salesforce Recycle Bin?

If your organization reaches its Recycle Bin limit, Salesforce automatically removes the oldest records if they have been in the Recycle Bin for at least two hours. The same is true from Apex, you can only recover records for 15 days (unless you open a case with support). If you want to recover deleted records, you must undelete them as follows:

image


How do I find out who deleted a class in Salesforce?

Salesforce administrators can determine who deleted a record by looking at the Recycle Bin or querying for deleted records via API….Use the Data LoaderIn the Data Loader, click Export All.Select the object and choose the target for export file. … Click Select all fields.More items…


How do I restore a deleted file in Salesforce?

To restore all deleted items, check the box in the column header and then click Undelete. When you undelete a record, Salesforce restores the record associations for the following types of relationships: Parent accounts (as specified in the Parent Account field on an account)


Can I delete an Apex class in Salesforce?

Apex classes and triggers cannot be deleted from a Salesforce production declaratively, unlike in sandbox orgs. This is because security for Apex in Salesforce production orgs is greatly increased.


How do you restore a record after it has been deleted?

After you have deleted records, the records are placed in the Recycle Bin for 15 days, after which they are permanently deleted. While the records are still in the Recycle Bin, you can restore them using the undelete operation.


How do I recover data from Salesforce?

If the record is visible in the Recycle Bin, select that item and click Undelete to restore it, review View, Restore, and Manage the Recycle Bin in Salesforce Classic.


How do I find the Recycle Bin in Salesforce?

Salesforce admins can see all deleted data across the entire org. The Recycle Bin is available in the left sidebar on the Home page….Search for Items in the Recycle BinChoose My Recycle Bin or All Recycle Bin. … Enter your search terms. … Click Search.


How do I get an inactive Apex class?

How to Deactivate/Delete the Apex Class/Triggers in ProductionDEACTIVATE THE TRIGGER IN SANDBOX AND DEPLOY. This is the simplest way to do of all is Deactivate your trigger in your sandbox by unchecking the Active checkbox of the trigger. … COMMENT YOUR TRIGGER CODE. … CREATE CUSTOM SETTINGS. … USE ECLIPSE IDE. … USE ANT. … WORKBENCH.


How can Apex classes be deleted from production instances?

These steps finally worked:Create project from sandbox in IDE.Delete the class in the sandbox.Refresh all classes in the IDE from server (sandbox). Status of package is now “Deleted”.Deploy all classes from IDE to server.Uncheck all classes except the one I want to delete.Execute deployment – Success – Log shows:


Can we delete Apex class in sandbox?

1. Probably the simplest way to delete / disable is to connect to your Salesforce production org from VS Code download the apex class / trigger, change the status of the Apex class / trigger to “Deleted” or “Inactive” in the class/trigger XML file and save.


Can we retrieve hard deleted records in Salesforce?

Once hard deleted, you will no longer be able to locate the record through the user interface, but for a time you can still see the record through API tools such as the Data Loader. Once it is this status, there is no way to recover or undelete the original record and it will need to be recreated.


How do I query a deleted record in Salesforce?

Query Deleted and Archived records with SOQLAdd “ALL ROWS” in the end of the query if it’s in the system log / API.Check the “include” button in “deleted and archived records” if you use the workbench.Use “Where isArchived = TRUE” if it is in the schema explorer or API.

Leave a Comment