PowerApps Portals - Webapi CRUD Operations, FINALLY!
Many of us, PowerApps Portals (a.k.a. Dynamics 365 Portals) developers, have stumbled upon a need to post Dynamics 365 Webapi calls directly from a PowerApps Portal page (form) in a secure fashion.
In this article I would like to show you a project I have been working on that delivers such functionality. Please keep in mind that the overall solution is at very early stage and needs to be thoroughly tested, refactored and packaged formally later.
Here is the idea:
I created a custom entity that stores Dynamics 365 Webapi request information. I called it "Webapi Operation".
Once a record is created, a plugin invokes the Dynamics 365 Webapi various methods (GET, PUT, PATCH, DELETE) based on the data entered on the "Webapi Operation" record.
The Plugin retrieves the response and stores the data unto the entity.
Sample flow using PowerApps Portals Entity Forms
A Portal page that creates a request record using the "Webapi Operation" entity.
Once the record is saved, and the plugin executes the Dynamics 365 Webapi call, the page redirects to a results page that shows the response from the webapi call.
The "Webapi Operation" entity is protected via "Entity Permission" configuration, only allowing signed on portal users to post against it.
Using the strategy above combined html and javascript developers will be able to build enhanced UI components while leveraging the full power of the Dynamics 365 Webapi.
If you would like to test it out please click the link below to download the managed solution and the portal configuration file, and follow the instructions below.
Import the PowerAppsPortalsWebApiExtensions_0_0_0_2_managed.zip solution into your environment.
Import the Portals configuration file powerApps-portals-webapi-0.0.0.2.xml using the XrmToolBox Portal Records Mover tool.
Register an app with Azure Active Directory. (https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/walkthrough-register-app-azure-active-directory).
Register Application user in Dynamics 365. (https://docs.microsoft.com/en-us/dynamics365/customer-engagement/admin/create-users-assign-online-security-roles)
Configure the "Eyedeas.PowerApps.Portals.WebApi" plugin with your environment's credentials.