I want to delete records of different objects, I have 4 object that i need to check if they exist and if it is the case i want to delete them. My problems is if for example the first object is not found I'll get an error and the flow is stopped. I found a workaround : connect the fault path to the next action(delete record) Is there a way to achieve that without the fault path.
-
You can add decision steps to check if your record actually exists and skip the delete step if there's nothing to delete. It's hard to get into specifics without understanding how you're querying for these related records and their relationship to your Account object.– nbrownCommented Nov 15, 2021 at 16:30
1 Answer
Welcome to Salesforce Stack Exchange (SFSE)!
Since you do not show the details of your Delete Records steps, I am assuming that within each of those you are specifying the correct conditions as to which records to delete. Otherwise you will never have any records to delete.
The only way I can think of doing this without using the Fault paths, is to create Get Records elements that attempt to explicitly retrieve the records that you want to delete.
Then add a Decision element after that and prior to each Delete Records element.
- If records exist, go to the Delete Records element.
- If no records exist, go to the next Get Records element. (Or go a completely different route if there will be no downstream records to delete if there are no upstream records, or if there is just another route you wish to take.)
Or, using Auto-Layout:
(For demonstration purposes I created a record variable called "CB_Susbcription_Record_Collection". You could create one, or just use the default internal Flow record collection variable associated to the Get Records element you use to retrieve the CB Subscription records.)