Power Community

Power Community

Check permissions like a Pro Low Coder

When you develop an app using Dataverse, you might have a button to update data in Dataverse. How do you check permissions before Power Apps tells you that the Patch function has failed?

Network error when using Patch function: You don't have permission to create this row.

Updating data

Using the Patch function we can update or create a record in Dataverse or any other data source. To Create a record in for example the Account Table you could use the following code

Patch(Accounts,{'Account Name': TextInput1.Text})

Now what happens if a user doesn’t have access to the Accounts table?

Network error when using Patch function: You don’t have permission to create this row.

Check permissions on a data source

But what if users don’t have permissions to the table? Can we first check the permissions before reading or updating data?

If we want to avoid error messages, we could include a check of the permissions on the Accounts table before we update the Accounts table.

Check permissions like a Pro Low Coder Microsoft Power Apps image 13

However the better way is probably to disable the button, that does the patch depending on the permissions of the user. Or maybe even make the form read-only depending on the Datasource permissions.

Check permissions with DataSourceInfo function

The other options available within Power Apps are listed ion the table below. These can also be found on the Microsoft documentation

Information ArgumentResult TypeDescription
DataSourceInfo.AllowedValuesBooleanWhat types of permissions can users be granted for this data source? If not set by the data source, returns blank.
DataSourceInfo.CreatePermissionBooleanDoes the current user have permission to create records in this data source? If not set by the data source, returns true.
DataSourceInfo.DeletePermissionBooleanDoes the current user have permission to delete records in this data source? If not set by the data source, returns true.
DataSourceInfo.EditPermissionBooleanDoes the current user have permission to edit records in this data source? If not set by the data source, returns true.
DataSourceInfo.ReadPermissionBooleanDoes the current user have permission to read records in this data source? If not set by the data source, returns true.

So with these few checks you can catch the errors before they occur. So like with the try catch pattern in Power Automate to ensure that you handle errors. Every update of data in Canvas apps should be preceded by permission checks on the data sources to ensure that low code is developed in a pro code way.

Further thoughts

Should you check a user’s permission when they start the app, so that they don’t waste any time trying to do something that that can’t? The App start up could be a good place to check all the permissions and warn the user or at least handle the user’s permissions.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

5 Benefits of In-App Notifications for Microsoft Dynamics 365 CRM users

For a successful sales process, you need to stay up-to-date with crucial sales information like deal closures, opportunities won,...

More Articles Like This

- Advertisement -spot_img