In Project for the Web, any user that has a project shared with them can delete the entire project, without being able to revert the deletion if this was done by accident. Teammates can also delete shared projects without having a project license when using Project Power Apps.
To limit this from happening, you can use Dataverse plug-ins to disable the delete operation on projects for a user based on any Dataverse condition that you determine. In the plug-in in this example, we will be removing the delete permission from a user that is not in a specific Team in Dataverse. Dataverse Teams can be backed by a M365 Group or created manually.
As a Dataverse Admin, I want to limit who has permissions to delete projects in Project Power Apps and Project for the Web.
To use this code sample, you need the Official Dataverse plug-in pre-requisites, which you can find here.
Please visit the Official documentation to Write a Dataverse Plug-in for latest updates. A step-by step to use this sample plug-in is provided below for convenience.
IMPORTANT: In the ProjectBlockDeletePlugin.cs file where commented TODO, you need to manually enter the Team Id give delete privileges to. You can find these in Power Apps Data Explorer.
- Sign the Assembly:
- Right click the project in your Solution Explorer and press Properties.
- Go to the Signing tab, check Sign the assembly, Choose <New…> from the dropdown options and name your signature. Password is optional.
- Build your solution by right clicking the project in your Solution Explorer and pressing Build.
- Launch the Plugin Registration Tool (installed in Prerequisites).
- Press the Create New Connection button at the top left and enter the account from which you want to register the plugin to Dataverse.
- Register a new assembly.
- Load the assembly from the .dll previously built, which is stored in your project’s Debug folder.
- Press Register Selected Plugins.
- Find your Plugin Assembly in the list of Registered Plugins and right click to Register a new Step.
- Register the step with the following changes:
- Message: Delete
- Primary Entity: msdyn_project
- Event Pipeline Stage of Execution: PreValidation
- We’re done! You can now test manually in Project Power Apps and Project for the Web to verify functionality.
- Project Blog Post on how to write this plug-in from scratch, with photos.
- Official Dataverse Plug-In Documentation
Copyright (c) 2016 Microsoft. All rights reserved.