Triggering Dataverse Plugins from Power Pages (Portals)
Power Pages (formerly Power Apps Portals) allow you to trigger Dataverse Plugins—custom business logic written in .NET—directly from portal actions, enabling deeper backend integration and automation.
Key Methods to Trigger Plugins from Power Pages
1. Entity Form or Basic Form Submission
- When a user submits a form (Create or Update), a Dataverse plugin registered on that table and message (like
Create
,Update
, orDelete
) will trigger automatically. - Example: A plugin on the
Contact
table with theCreate
message fires when a portal user submits a “Register” form.
2. Custom Workflow Action (Process)
- Use a custom action in Dataverse that is exposed via the Web API or Power Automate, and bind the plugin to that action.
- Trigger the action using:
- JavaScript Web API call
- Liquid with a custom button
- Power Automate (if initiated via form submission or web role)
3. Using Web API (JavaScript)
- Create custom JavaScript in the portal to perform CRUD operations via the Dataverse Web API, which can trigger plugins.
// Example: Creating a contact to trigger the plugin
var data = {
"firstname": "John",
"lastname": "Doe"
};
webapi.safeAjax({
type: "POST",
url: "/_api/contacts",
contentType: "application/json",
data: JSON.stringify(data),
success: function (res) {
console.log("Plugin triggered via Create!");
}
});
Tips & Best Practices
- Ensure the plugin is registered on server-side operations (not async workflows that don’t execute in portals).
- Use Pre-Validation or Post-Operation stages depending on your requirement.
- Avoid infinite loops—set a flag or check source (e.g., check if
InitiatingUserId
is a portal user). - Use ExecutionContext.Depth to prevent recursive calls.
Security Consideration
- Plugins triggered by portals run under the portal service account’s Dataverse privileges.
- Make sure to implement security checks in the plugin if needed (e.g., validate user roles or web roles).
Summary
You can trigger plugins from Power Pages through:
- Entity Form submissions
- Web API calls using JavaScript
- Custom Actions invoked from forms or buttons
This enables robust backend logic execution, including automation, validation, and third-party integration—all while keeping the user experience smooth.