Power Pages (formerly Power Apps Portals) allow users to create secure, external-facing websites that interact directly with Microsoft Dataverse, which underpins Dynamics 365. One common use case is triggering Dynamics 365 actions (or custom processes) when a user interacts with your portal—such as submitting a form, clicking a button, or completing a workflow. Here’s how to set that up, step-by-step.
Prerequisites
Before diving into the process, make sure the following prerequisites are in place:
- You have access to Power Pages (Power Apps Portals).
- You have a Dynamics 365 environment set up and access to Power Platform Admin Center.
- You have basic knowledge of Dataverse tables and actions.
- The action you want to trigger is already created in Dynamics 365 (can be a classic workflow, custom action, or Power Automate flow).
Step 1: Create or Identify the Action in Dynamics 365
In Dynamics 365, actions are custom processes that you can call via API or logic flows.
1.1 Using Classic Workflows (No Code)
- Go to Advanced Settings > Processes.
- Create a new Process:
- Name: “Portal Submission Action”
- Category: Action
- Entity: Choose the target entity (e.g., Contact, Case).
- Define the steps (e.g., update fields, send emails).
- Save and Activate the action.
1.2 Using Power Automate (Low Code)
- Go to Power Automate > Create Flow.
- Select Automated Cloud Flow.
- Trigger: When a row is added, modified, or deleted.
- Add conditions and actions to perform necessary logic.
- Make sure to trigger it from the correct table that your portal form interacts with.
Step 2: Set Up the Table/Form in Power Pages
The interaction point (usually a form) must be linked to a Dataverse table.
2.1 Create a Form in Power Pages
- Navigate to your Power Pages design studio.
- Add a page and insert a Basic Form or Multistep Form.
- Link it to the correct Dataverse table.
- Configure the form layout with required fields.
2.2 Enable Entity Permissions
- Go to Portal Management App.
- Create an Entity Permission:
- Table Name: Select the related Dataverse table.
- Permissions: Create, Read (minimum).
- Assign to a Web Role (Authenticated Users or custom).
- Ensure your portal users are assigned this web role.
Step 3: Use JavaScript to Trigger the Action via Web API
To call the action directly when a form is submitted, use JavaScript with the Dataverse Web API.
3.1 Add Custom JavaScript to Your Portal Page
Here’s a basic template to call an action:
function triggerD365Action(recordId) {
var serverURL = window.location.origin;
var req = new XMLHttpRequest();
req.open("POST", serverURL + "/_api/<entitylogicalname>(" + recordId + ")/Microsoft.Dynamics.CRM.<customactionname>", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200 || this.status === 204) {
console.log("Action triggered successfully");
} else {
console.error("Error triggering action: " + this.responseText);
}
}
};
req.send(null);
}
3.2 Add Event on Form Submission
Hook this function to the form’s On Save
or On Change
event:
formContext.data.entity.addOnSave(function(executionContext){
var recordId = executionContext.getFormContext().data.entity.getId().replace("{", "").replace("}", "");
triggerD365Action(recordId);
});
Note: This works only if your custom action is set as a bound action to an entity.
Step 4: Triggering Power Automate Flows
If you’re using Power Automate instead of custom actions:
4.1 Create Flow from Dataverse Trigger
- Trigger: When a row is added to the specific Dataverse table.
- Actions: Add logic like sending email, updating records, calling APIs, etc.
- Test the flow independently first.
4.2 Connect Power Pages Form to Flow
Since Power Pages forms update Dataverse directly, the Power Automate flow will be triggered automatically as long as it’s configured to watch the same table.
4.3 Optional: Use Power Pages Webhooks (Advanced)
For more real-time control, you can implement Webhooks via custom connectors or HTTP trigger flows using JavaScript and the Fetch API.
Step 5: Test the Integration
- Publish your Power Pages site.
- Fill out the form as a test user.
- Submit and monitor:
- Dynamics 365 action logs.
- Power Automate flow runs.
- Browser console logs (for JavaScript errors).
- Confirm the expected action took place (email sent, record updated, etc.).
Step 6: Security and Permissions
Ensure the following for a secure and functional setup:
- Portal users have correct Web Roles.
- Proper Table Permissions are set.
- If using Web API, the portal has the necessary OAuth/CSRF protection enabled.
- Limit action calls to authenticated users or add validation layers.
Best Practices
- Minimize JavaScript in browser: Prefer Power Automate when possible for logic.
- Use Dataverse triggers over custom APIs if business logic doesn’t require API-level execution.
- Log and monitor via Power Platform Admin Center or Monitor tool.
- Always test with realistic portal users.