Dataverse storage costs can be expensive.  If you want to automatically delete a file stored in a Dataverse file column that is no longer required, here’s how to do it

In this example,  whenever the status of a row in the ‘Appointments’ table is changed to cancelled, which is a change that would typically be made in a Power App, I want to delete a file stored in the ‘Agenda’ column because once the appointment is cancelled there is no need to retain the agenda

The flow is automated and has a Dataverse trigger.  I’ve set the trigger to fire every time a row of the Appointment table is modified.  To narrow it down to fire only when the Status of a row is changed to cancelled, the following OData code is added against Filter rows (check out the full flow at the bottom of the page)

stateode eq 2

The status of an Appointment is a choice and with choice columns, the value of each choice is required to identify the selection, rather than the choice title.  The choice value for a status of cancelled is 2, as can be seen from viewing the column details in Dataverse (shown below)

automatically delete a dataverse file

Next, we have a Condition step.  This is required because if the flow tries to delete a file that doesn’t exist, an error will be thrown. The condition simply checks whether the value of the Agenda column is null and if it is, then no further action is taken

If the value of the agenda column isn’t null and a file exists, the condition returns yes and the subsequent step ‘Perform an unbound action’ deletes the file

The Full Flow

This is a nice simple process, once the status of an Appointment is changed in Dataverse, the automated flow is triggered and the file is deleted

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top