Learn How to Delete Records Using Flows in Salesforce | The Developer Guide
- Go to Setup, enter flow in Quick Find then select Flows.
- Click on New Flow. From the template, select Screen Flow.
- Click on the + sign and select Screen from the Interaction.
- Give Label and API Name in Screen Properties.
- Click on Configure Footer, then in the Next or Finish section select Use a custom label and write Delete and select Hide Previous in the Previous Button section and Hide Pause in the Pause Button section.
- Search text in Search Component bar and select Text.
- Give Label and API Name as Account Id.
- Check the Require checkbox.
- Click on Done.
- Click on + icon after the screen element and select Delete Records.
- Give Label and API Name.
- In How to Find Records to Delete select Specify conditions.
- In Object select Account.
- In Filter Account Records,
- In Condition Requirements to Update Records select All Conditions Are Met (AND).
- In Field write id and select ID.
- Select Equals in Operator.
- Select Account_Id in Value.
- Click on Done.
- Click on Delete Records and select Add Fault Path.
- If your flow contains DML Elements such as Create, Update, or Delete, then there might be a possibility that it might fail. Instead of showing why it failed, salesforce display standard message “An unhandled fault has occurred in this flow” which might not be very useful to user.
- Add Fault Path is used to show a custom error message which can show meaningful errors and guide the user on what to do.
- You can even select connect to element to reroute the user to a different screen when an error occurs.
- Now on the Fault path line click on + sign and select Screen.
- Give Label and API Name in Screen Properties.
- Click on Configure Footer, then select Hide Previous in the Previous Button section and Hide Pause in the Pause Button section.
- Search text in Search Component bar and select Display Text.
- Give API Name as Error.
- Click on Insert a resource and select $Flow from Global Variables then select FaultMessage, it would look like this {!$Flow.FaultMessage}.
- Click on Done. Check out another amazing blog by Aryan here: Update Records Using Salesforce Flow | Salesforce Developer Guide
- Click on + sign after screen component in fault line and select Add to Element then click on the + sign on the 1 screen element you created it is used to reroute the user to the starting of the flow so user can enter right information.
- Click on + sign below Delete Record Element and select Screen.
- Give Label in Screen Properties as Result Screen and API Name will be auto populated.
- Click on Configure Footer, then select Hide Previous in the Previous Button section and Hide Pause in the Pause Button section.
- Search text in Search Component bar and select Display Text.
- You can write any message that you want to give to the user like Record Deleted Successfully.
- Click on Done.
- Click on Save, give Label and Api Name.
- Click on Debug to test the flow.
Responses