Use Flow to delete records related to Account using IsDeleted as a trigger - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Tom BarberTom Barber 

Use Flow to delete records related to Account using IsDeleted as a trigger

I have a "shadow" Account object. There is a record for each Account. Each record in the shadow object has a subset of Account fields related to Account via lookup. The shadow object is Public Read/Write and no hierarchy access. The purpose is so all users can lookup a few read only fields on Accounts and still keep the private sharing model in place for the real Account object.

Every time a new Account is created, I have Process Builder create a "shadow" record where the shadowed fields are formulas pointing to Account. Every time an Account is updated, Process Builder updates the "shadow" record.

The problem comes in when an Account is actually deleted. Since Process Builder cannot delete records, I created a simple Flow to do it and connect it Process Builder.

Trouble is, I can't get it to execute the delete. I think the problem may be that I am using the Account IsDeleted field in Process Builder to trigger the Flow. But because when IsDeleted=TRUE, the Account is already gone so it cannot execute the Flow.
  • Is this it?
  • If so, how else can I set this up?
__
I am led to this conclusion for these reasons:
  1. If I debug the flow and enter the Account ID as an input onto the debugger by hand, the Flow deletes the associated shadow record.
  2. If I swiitch the Process Builder trigger from IsDeleted=TRUE to [random checkbox field on Account]=TRUE, it all works fine.
Best Answer chosen by Tom Barber
Jonathan WieselJonathan Wiesel
Hi Tom,

​​​​​​The thing is that Process Builder is not fired on delete events, there's an idea about it so I recommend you vote it

https://success.salesforce.com/ideaView?id=08730000000DlPBAA0

You'll need to rely on an Apex trigger to handle the deletion logic.

All Answers

Jonathan WieselJonathan Wiesel
Hi Tom,

​​​​​​The thing is that Process Builder is not fired on delete events, there's an idea about it so I recommend you vote it

https://success.salesforce.com/ideaView?id=08730000000DlPBAA0

You'll need to rely on an Apex trigger to handle the deletion logic.
This was selected as the best answer
Tom BarberTom Barber
Thanks Jonathan. Disappointing, but after reading the Salesforce feedback on the Idea you reference I get that they are in the middle of a long journey trying to merge a bunch of these tools. Bit by bit it will get there.
Jonathan WieselJonathan Wiesel
Well the comment from Salesforce spokeperson around 7 months ago mentioning that it should be implemented in the next 12 seems promising, hopefully we could see something about it by the Summer release or Dreamforce at best ;)