How to Delete Records using Flow in Salesforce

In Salesforce, using the record-trigger flow, we can automate the process of deleting records that do not meet the required criteria.

In this Salesforce tutorial, we will learn how to delete records using flow in Salesforce, using real-time scenarios and step-by-step explanations.

Delete Record using Flow in Salesforce

While working as a Salesforce Admin for a US-based Organization that provides software solutions, I was assigned the task of if we get any opportunity in the “Close Lost” stage, then that opportunity should get deleted automatically.

To create this process automatically, we can create a record trigger flow, which will trigger on the opportunity stage changes into Close Lost, and then that record gets deleted. This will be useful to the organization for deleting records that do not meet business criteria or are not required.

Using the above scenario and the following steps, we can delete records using Salesforce Flow.

1. Log in to Salesforce Org. -> Click on the Setup -> Home Tab -> In Quick Find Box, Search for Flows. You will see an option under Process Automation -> Click on Flows.

Delete Record Using Flow in Salesforce

2. Then, click on the New Flow button to create a new flow.

Delete Record in Salesforce Flow

3. We know the record trigger flow launches when the record is created, updated, or deleted. When the opportunity stage is updated or changed to “Close Lost,” the record will be deleted. To do that, we have to select the Record Trigger flow and click on the Create button.

Delete Record using Salesforce Flow

4. As we click on the create button, we will see the flow canvas. In our scenario, the flow should trigger when we update the Opportunity record, so I selected the Opportunity in the Object field.

See also  How to Create Roll-Up Summary Field using Salesforce Flow

In Configure Trigger, I have selected A Record is Updated because when we Update the opportunity stage to “Close Lost” the record, the flow should trigger.

How to Delete Record in Salesforce Flow

5. Then, we have to Set Entry Conditions, and in the Condition Requirement option, we have to select All Conditions Are Met(AND) because the following condition should meet the criteria.

Our triggering condition is when StageName is equal to “Close Lost.” Then, the trigger should fire.

Then we need to select Every time a record is updated and meets the condition requirements: When you select this option, every time you update the record, the flow will trigger.

We are going to update the opportunity records and want to delete those records whose oppo stage is close lost, so we have to select Optimize the Flow for Action and Related Records.

How to Delete Record Using Flow in Salesforce

6. Now, we need to add the Delete Record element. To Add Element, click on the + plus icon, and then under the Data component, you can see Delete Record. Click on it.

When we click Delete Records, we have to enter the Label, which will display on the flow canvas. The API Name will automatically populate.

7. Then, we need to select How to Find Record to Delete. Here, we need to provide the current RecordID to the Opportunity ID. For that, select Specify Conditions, and in the Object field, select Opportunity object.

Then, specify the current RecordID to the Opportunity ID.

How to Delete Record using Salesforce Flow

8. After setting up all labels and conditions, first save the flow. You can see the Save button. Click on it and then click on the Debug button. Then click on the Activate button; always remember to debug the flow before activating it. It’s good practice to use flow.

Delete Record Using Flows in Salesforce

9. Then, click the Save button to save the flow. For that, we need to enter the Flow Label; here, I have entered Delete records for specific conditions. The API Name will automatically populate as we click the text box. The Description is optional; we can introduce our flow Shortly.

Delete Record in Salesforce Flows

10. After that, to check whether the flow is working, go to the Opportunity record and try to update any oppo stage “Close Lost,” and then Save the changed record. Then, go to the Recycle Bin to see the deleted record.

How to Delete Records in Salesforce Flow

11. As you navigate to the Recycle Bin, you will see which record you have updated to close the lost stage in the opportunity object. That record is deleted and stored in the recycle bin.

Record Deletion Using Salesforce Flow

This is how we can delete the records using flow in Salesforce.

See also  Two Ways to Post to Chatter Using Salesforce Flow


I hope now you have an idea about how to delete conditional records that are not required by the business criteria. In that, we have seen how to delete records using flow in Salesforce with scenario and explanation.

You may like to read: