In Flow Builder, you can get records of almost any object from the database. You just have to use the Get Records element and select the object that you want to get the records. Optionally (most of the time you need this) you can enter a criteria to filter the records. Flow will get the records according to your condition and store the records in a variable. However, all the records that it will find are undeleted records. What if you want to access deleted records?
Every object has a read only checkbox field called isDeleted. This field is not available on the UI (actually, it wouldn’t make sense to have it on the UI). It becomes “true” when the record is deleted, so you might try to get records that isDeleted equals to true. However, flow will not find these records since they are deleted.
Where are the Deleted Records?
Deleted records aren’t deleted permanently from Salesforce, but they are placed in the Recycle Bin for 15 days from where they can be restored. You can see those records from the Recycle Bin in Salesforce Lightning, it has its own tab. There you will be able to see your recycle bin and org’s recycle bin (if you have admin permissions). From this tab, you can create list views and select records to restore or permanently delete them.
How to Access Deleted Records in Flow?
Deleted records are stored in an object called DeleteEvent, which is known as Recycle Bin Item. In Flow, it is possible to get records from this object but it does not let you create, update, or delete records from this object. You can just query it.
This object stores the sObject name, record Id, record name, deleted date and deleted by Id. Using these fields, you can add a condition to get deleted records of a specific object or a specific user.
In the example below, flow gets all the deleted accounts. It is important to note that, recycle bin rules apply here. So it means if a record is permanently deleted, then flow cannot get it.
After getting the deleted records, you can display them on a screen or display them as record choices. However, as mentioned before, it is not possible to modify these records.
Using some great flow screen components from Unofficialsf, you can build very useful flows. If you are willing to display the deleted records on a flow screen, I recommend you to display the deleted records in a datatable, which can be installed from here.
Where to Use?
If you just need to display the deleted records, you can simply use the Recycle Bin and create filtered list views, you don’t need to create a flow for this purpose. I know that most of the time you won’t need it, but it is good to know how to get the deleted records. Who knows, one day you might need to do something about the deleted records in one of your big flows, so just keep this in your mind.