Monday, November 25, 2019

Undelete trigger event in apex trigger in Salesforce


Before Undelete

The record is available, but the field isDeleted set to True. the before undelete trigger wouldn’t be able to see the records(values) that it needs. due to this reason, there is no before undeleting operation available.

After undelete

The after undelete trigger event only works with recovered records—that is, records that were deleted and then recovered from the Recycle Bin through the undelete DML statement. These are also called undeleted records.

Ex:
If you delete an Account, an Opportunity may also be deleted. When you recover the Account from the Recycle Bin, the Opportunity is also recovered.
If there is an after undelete trigger event associated with both the Account and the Opportunity, only the Account after undelete trigger event executes.

The after undelete trigger event only fires for the following objects:

  • Account
  • Asset
  • Campaign
  • Case
  • Contact
  • ContentDocument
  • Contract
  • Custom objects
  • Event
  • Lead
  • Opportunity
  • Product
  • Solution
  • Task

1 comment:

  1. After undelete trigger event will work on all custom objects?

    ReplyDelete