Triggering Salesforce Workflow/Process Builder when record is deleted

As of to date, Salesforce does not provide an object’s isDeleted flag as a filter criteria through workflow rule or process builder. This may lead to the option of utilising Apex Triggers if a requirement is to perform a certain action when a record is deleted.

 

However, triggering a process builder/workflow is still possible when a record is deleted. Please consider the following criteria prior to designing your workflow or process builder in this case:-

  • the target object (to update field or to do something about it) is a parent to the deleted record
  • the target object and the deleted record is in master-detail relationship
  • the target object has capacity for additional roll-up summary field

 

Take Account-Opportunity for example. You may want to perform an action (i.e. update a field, send an email alert, etc.) on the account where when one of its opportunity is deleted. As an alternative to utilising Apex Triggers, following are the steps that you may consider as a workaround to utilise Salesforce workflow/process builder instead:

  1. Create a roll-up summary field into account that counts the total opportunities which the account belongs to. In this example, we call it “Total_Opportunities__c”
  2. Define a workflow or process builder and utilise the evaluation criteria of “created, and every time it’s edited”
  3. Use the rule criteria of “Formula evaluates to true”
  4. Compile a formula which compares if the current “Total_Opportunities__c” is lower than the prior value. For example ${the_Roll_Up_Summary_Field} < PRIORVALUE(${the_Roll_Up_Summary_Field})
  5. Followed by the intended actions at the parent level

Get in touch today to see how WDCi can help your business.