Power Pages — Create Custom Button to Update Data via Web AP
Power Pages Tutorial — Create a Custom Button to Update Data via Web API
In this tutorial, you’ll learn how to create a custom button in Microsoft Power Pages (formerly Power Apps Portals) that updates data in Microsoft Dataverse using the Web API.
This step-by-step guide will help you securely perform server-side updates (PATCH calls) from your portal form with proper token-based authentication.
We’ll take the Sales Order form as an example and build a “Submit to BC” button that changes the order’s status when clicked.
Objective
After completing this tutorial, you’ll be able to:
-
Add custom action buttons to Power Pages.
-
Safely call Dataverse Web API using JavaScript.
-
Use the
PortalWebapiJSWeb Template to manage authentication. -
Configure and enable entity-level Web API permissions.
-
Test the complete integration end-to-end.
Step 1: Create a Custom Button in the Power Pages Form
-
Open your desired form (e.g., “Edit Sales Order”).
-
Click + Add → HTML text in the form layout.
-
Paste this code inside:
<a href="#"
id="submitToBCBtn"
class="btn btn-primary"
style="font-size:13px; padding:4px 10px;">
Submit to BC
</a>
In Power Pages Studio, click Edit Code (top-right) and approve VS Code access.
-
Open the file:
web-pages/Edit Sales Order.en-US.webpage.copy.html
-
This file defines the HTML and script for your Sales Order form.
Step 3: Include PortalWebapiJS and Add JavaScript
At the very top of your HTML file, include the PortalWebapiJS template:
Comments
Post a Comment