Process Builder - Run a Process when a record has been deleted - Answers - Salesforce Trailblazer Community
Ask Search:
Sarah BurtonSarah Burton 

Process Builder - Run a Process when a record has been deleted

I have a Process Builder workflow that triggers when a product has been added to an opportunity and meets a certain criteria. A field on the Opportunity it updated to 'true'. However, if that Product is deleted I need to clear the field or update it to say 'False'. I'm trying to use the IsDeleted feature and it just wont work... 

User-added imageUser-added image
I'm not sure if this is conflicting with the workflow that triggers when the product is created? However, there is a criteria on this that says is Deleted is false so the 2 should be differentiated? 

I'm very confused! Thanks in advance, Sarah
Best Answer chosen by Sarah Burton
Mayank SrivastavaMayank Srivastava
Sarah, 
A process or workflow rule cannot fire when a record is deleted. They can only fire when a record is created or edited. The Deleted field that you are using is just a custom field and not some logic/standard criteria that you can use in a Process.

Instead of taking the above route, do the following:

1. Create a Roll Up summary field on Opportunity that counts the number of Opp Products that meet that certain criteria.  (just an example below):

User-added image

2. Then create a formula field of checkbox type that has the following formula:
Roll_Up_Opp_Product__c > 0
User-added image

Now whenever you Opp product is added to the Opportunity, the checkbox above will be checked and when the product is removed, the checkbox will be unchecked. 
 

All Answers

Mayank SrivastavaMayank Srivastava
Sarah, 
A process or workflow rule cannot fire when a record is deleted. They can only fire when a record is created or edited. The Deleted field that you are using is just a custom field and not some logic/standard criteria that you can use in a Process.

Instead of taking the above route, do the following:

1. Create a Roll Up summary field on Opportunity that counts the number of Opp Products that meet that certain criteria.  (just an example below):

User-added image

2. Then create a formula field of checkbox type that has the following formula:
Roll_Up_Opp_Product__c > 0
User-added image

Now whenever you Opp product is added to the Opportunity, the checkbox above will be checked and when the product is removed, the checkbox will be unchecked. 
 
This was selected as the best answer
Sarah BurtonSarah Burton
Sadly this won't work because we use 'Product' not 'Opportunity Product'. 
I need to filter by 'Product Name' which is what the problem is
 
Sarah BurtonSarah Burton
This helped me: https://success.salesforce.com/answers?id=90630000000gsDnAAI
Also I was curious between Products and Product opportunuities and this helps: https://success.salesforce.com/answers?id=90630000000h3cmAAA
Mayank SrivastavaMayank Srivastava
Glad you got it figured out. Google can be your best friend during such times :)
Sarah BurtonSarah Burton
Absolutely! Sometime it's just figuring out what to search for :) You definitely helped me on the right path though! 
Rodrigo RosalRodrigo Rosal
Sarah, What was the folution you came up with for this? I am also trying to do the same thing.
Tim CombridgeTim Combridge
Hi everyone!
I know it's been quite a while since this was asked and answered, but I have a solution that MIGHT suit your needs. It demonstrates how records can be handled declaratively using Flow when they have been deleted. There is a LITTLE bit of code, but that can be copied directly from my article and tweaked.
https://www.liquid.com.au/blog/declarative-record-deletion-handling-without-process-builder-in-salesforce-crm 
Please let me know if this helps! 
Varghese DanielVarghese Daniel
Hi Tim,
The link you provided as a solution throws 404 error. Any alternate links?
Nik Friedman TeBockhorstNik Friedman TeBockhorst
https://www.liquid.com.au/insights/3-foolproof-ways-to-avoid-having-to-hire-a-salesforce-consulting-partner-1-2
Melanie HarmonMelanie Harmon
I have this exact use case, as originally stated. Nik, I appreciate the article and the trigger, but I can't create a trigger in my org without going through our Developer.  I don't actually understand how triggers are written.  In recent months, have there been any advancements with Flow or Process Builder that would enable this issue to be resolved 100% declaratively?  The Roll-Up Summary field idea is great and that's actually how I'm solving the problem for a couple of products, but we're at our max of 25 Roll-Up Summary fields and I need to create 3 more of them to resolve the issue.  I'm running a Field Footprint on Opportunity now to see if I can delete any unused Roll-Up fields.  I'm hoping a trigger isn't still the only other option.  If so, maybe I can request more Roll-Up fields.
NPFL FOOTBALLNPFL FOOTBALL
Dont have any answer for now but you can find useful ideas on https://worldbestinfo.com/