I want to build a screen-flow which runs a Delete action on a record in system mode (ignores user permissions). I want to implement this same screen flow on multiple objects (~10 in total).
I would ideally like to build the screen flow in an object-agnostic way, such that it only needs 2 inputs:
- Record ID
- Object API
The flow would then pass these 2 parameters into 1 Delete element to delete the record. From what I can tell, it doesn't seem possible to dynamically pass variables into the Delete element, so my only 2 remaining options are:
- Use a decision node + separate delete elements
- Use an invocable Apex method (which can be built to dynamically receive those 2 inputs I listed above)
However, even in those 2 alternative solutions, I still need a way of automatically detecting what Object the flow has been launched on. How can that be done?
Any thoughts or advice on this solution would be appreciated!
Best Answer
All you need to delete the records is the
recordId
to query the records and delete it.Note you don't need the Object Name at all for your use case if it is just deleting the records.
Now to make it dynamic, use your second approach of creating a simple Innvocable action via apex that takes in ID and deletes it.
A Sample pseudo-code is below,