When we are doing business with a customer, we create an account and mark it as Active. Also, when we stop working with that customer, the user sets that account as deactive.
The requirement is that whenever a user marks an Account as not active and saves the record, Salesforce should automatically delete that Account.
A Record-Triggered Flow will check if Account_Active__c is set to False. If it is False, the Flow will automatically delete the Account record without any manual work.
In this article, we will learn how to automatically delete records using Salesforce flows, using real-time scenarios and step-by-step explanations.
Delete Records Using Salesforce Flows
I was assigned the task: if we get any opportunity in the “Close Lost” stage, it should be deleted automatically.
To create this process automatically, we can set up a record trigger flow that triggers when the opportunity stage changes to Close Lost, and then the record is deleted.
This will be useful to the organization for deleting records that do not meet business criteria or are not required.
Create Record Trigger Flows in Salesforce
Using the above scenario and the following steps, we can delete records using Salesforce Flow.
- Log in to Salesforce Org. -> Click on the Setup -> Home Tab -> In the Quick Find Box, Search for Flows. You will see an option under Process Automation -> Click on Flows.

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

- 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.

- 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.
- 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.

- Then, we have to ‘Set Entry Conditions‘, and in the Condition Requirement option, select All Conditions Are Met (AND) because the following condition must meet the criteria.
- Our triggering condition is that StageName equals “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, the flow will trigger every time you update the record.
- We are going to update the opportunity records and want to delete those records whose opportunity stage is ‘close lost’. We need to select ‘Optimize the Flow for Action and Related Records‘.

- 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 that will appear on the flow canvas. The API Name will automatically populate.
- 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 for the Opportunity ID.

- After setting up all labels and conditions, save the flow first. You can see the Save button. Click it, then click 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.

- Then, click the Save button to save the flow. For that, we need to enter the Flow Label; 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.

- After that, to check whether the flow is working, open the Opportunity record, try to update the “Close Lost” stage, and save the record.
- Then, go to the Recycle Bin to see the deleted record.

- 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.

This is how we can automatically delete the records using a flow in Salesforce.
Conclusion
I hope you now have an idea of how to delete conditional records that do not meet the business criteria. In that, we have seen how to delete records using a flow in Salesforce with a scenario and explanation.
You may like to read:
- Delete Related Records Using Flow Action in Salesforce
- Clone a Record with Flow in Salesforce
- Delete Custom App in Salesforce
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.