With this movie we will show you how to delete a folder, related to a database record when deleting the record.
DMXzone File System Connector Manual
We will show you how to delete a folder, related to a database record when deleting the record from the database. In our previous tutorial, you learned how to create a dynamic upload folder using the inserted record identity. Now you will learn how to remove it, when the record is deleted. We already know how to create a delete record server action and how to execute it. Note! In order to learn how to do this, please watch the delete database records tutorial. We've already setup the delete record action and applied it to the delete button in our repeat region. Now, let's setup the delete folder functionality. Right click the database connection step, of the delete action. Open the database actions menu. And add a database query (1). Open the query options (2). Select and add the database table, that you are using in the database delete step (3). And then add its columns to the selected columns list (4). Switch to filters tab (5).
And add the ID column, to the filters list. Just as you did in the database delete step.Then, click the dynamic button, in order to select the value for this filter.
Then, under the post variables select the same variable, that you are using in the delete record step. And click the select button.
Then, click OK. Now, right click the database query. And under core actions Select add repeat (1). Click the dynamic data button, in order to select an expression for this repeat (2). The expression should be the database query step, which we've created. It will return the records, returned by the filter (3). Click the select button.
And then, right click steps, in the repeat, that we've just created. Open the file management menu. And select add remove folder (1). Click the dynamic button, in order to select the folder path (2). Our folders are using the record IDs for names. So we select the record ID binding, returned by the query (3). Then, click the select button.
The folders, related to our database records, are located in another folder, in our site root so we just manually enter the path to the containing folder. And we are done. Save the server action. On our server, we currently have 4 folders, related to 4 records in our database. Let's run the delete action, in order to remove a record. Let's delete the record with the ID of 5. This should also remove the folder named 5. You can see, that the folder has been successfully removed from our server. that's how easy it is to remove a folder, when deleting a database record.