Loading
ただいま大変多くのお問い合わせをいただいており、ご連絡までにお時間を頂戴しております続きを読む

Cannot Recover a Deleted Salesforce Apex Class or Trigger

公開日: May 23, 2026
説明

In Salesforce, once an Apex class or Apex trigger is permanently deleted from an org, it cannot be recovered. Salesforce does not maintain a recycle bin or restore mechanism for Apex code metadata. This is different from Salesforce record deletion, where the Recycle Bin allows recovery within 15 days. To prevent data loss, developers must maintain their own backups of all Apex code.

解決策

Why Apex Code Cannot Be Recovered

Apex classes and triggers are stored as metadata in the Salesforce metadata repository. When deleted, they are immediately and permanently removed from the metadata layer. Salesforce Support cannot restore deleted Apex code through any process.

Best Practice: Maintain Code Backups

Developers are strongly encouraged to maintain up-to-date backups of all Apex code. Recommended approaches:

  1. Version Control System (VCS): Use a tool such as Git to track all Apex code in a repository (e.g., GitHub, GitLab, or Bitbucket). This is the most reliable backup strategy.
  2. Salesforce CLI: Run the command sf project retrieve start regularly to export org metadata to your local development environment.
  3. Salesforce DX and Unlocked Packages: Use scratch orgs and unlocked packages to store Apex code in version-controlled source format.

Preventing Accidental Deletion

Before deleting any Apex class or trigger in a production org, ensure the code is backed up. Make all metadata changes in a Sandbox first and deploy using change sets or Salesforce CLI after review.

ナレッジ記事番号

000386045

 
読み込み中
Salesforce Help | Article