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 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 email alert, etc.) on the account where when one of its opportunity is deleted. As an alternative to utilise 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 in 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 priorvalue. For example ${the_Roll_Up_Summary_Field} < PRIORVALUE(${the_Roll_Up_Summary_Field})
  5. Followed by the intended actions at the parent level

Wedid: Salesforce Skedulo Case Integration

Challenges

This companies main revenue source is derived from the repair services and additional products they provide to the commercial and residential business.

The technicians are required to repair items, keep track of replacement products issued to the customers, collect signatures, take images of the issues found, advise the next technician to onsite of the job requirements and what they foresee the next technician will be required to complete.

The challenge for this solution was that there would be up to 3 job visits, each job visit containing data that would need to be passed from one technician to another, without any phone or email communication.

Solution:

In the case, we used Apex trigger in conjunction with Skedulo and a custom Visualforce page to send the user to the Skedulo Web Browser for scheduling.

We used standard and custom fields created in Salesforce and Skedulo to capture some of the following data:

  • Products used
  • WHS issues identified or not
  • Signature Collected
  • Marketing Questions answered
  • Contact Details checked and updated
  • Images of site collected
  • Any expenses

There was a two-way sync with different trigger points between Skedulo and Salesforce allowing the data to flow back and forth.

Integrating the case with Skedulo enabled the client to automate communication between their field technicians and administration staff, reduce the paperwork created from each job, have a live status update running on each job/case for an enriched customer service and communication experience.

Related Objects Case, Skedulo Job, Product, Pricebook, Pricebook Entry
Components VisualForce, Trigger
Complexity Medium