Plugins

Plugins are server‑side code that run within the Dataverse execution pipeline. They allow you to extend Dynamics 365 beyond what configuration and low‑code tools can offer. Plugins provide powerful, reliable and high‑performance automation for business‑critical scenarios.

This page explains when plugins should be used, how they differ from Power Automate flows, and the best practices to follow when building and deploying them as part of a Dynamics 365 solution.

When to Use Plugins

Plugins should be used when the requirement is too complex, too performance‑critical, or requires synchronous execution in a way that configuration or Power Automate cannot support.

Plugins are appropriate for:

  • Complex business logic with multiple conditions or branches
  • Synchronous validation that must run immediately before or during a save event
  • High‑performance automation where latency matters
  • Transactional operations and operations requiring rollback behaviour
  • Logic that must apply even if users bypass the UI
  • Advanced manipulation of related records
  • Controlling or overriding default platform behaviour (not typically recommended)

Use a plugin when:

  • The logic must run before or during a save (not afterwards)
  • The system must guarantee the logic runs every time or produce an error
  • Performance and scalability are important
  • Power Automate would be too slow, too fragile or too complex
  • The requirement involves deep Dataverse integration or multi‑step logic

Examples of When Plugins Are Suitable

  • Enforcing complex server-side validation rules before data is committed
  • Automatically creating or updating related records synchronously
  • Controlling record ownership, access or business process flows
  • Implementing custom calculation engines or scoring models
  • Enforcing cross‑table rules where timing and order matter
  • Creating advanced integration hand‑offs or routing logic
  • Applying business rules that must run even via bulk imports or APIs

These are patterns that low‑code tools often struggle with, in terms of either performance or reliability.

Best Practice When Using Plugins

To ensure plugins are reliable, maintainable and follow DfE’s standards, follow these best practice points:

Keep plugins focused and modular

  • Implement single‑responsibility classes
  • Avoid placing unrelated logic into large plugins
  • Break complex processes into multiple steps or handlers

Follow coding standards

  • Use consistent naming conventions
  • Include comments, logging and clear error messages
  • Follow standard C# patterns and Dataverse SDK best practice
  • Version‑control all plugin code along with the solution

Control when plugins run

  • Register steps only on the required message and entity
  • Avoid unnecessary triggers that create performance load
  • Use filtering attributes to limit plugin execution to relevant fields

Use Pre and Post operation stages appropriately

  • Use Pre‑operation for validation or modifying the target entity
  • Use Post‑operation for creating related records or calling external services

Handle errors safely

  • Ensure exceptions are descriptive and actionable
  • Avoid leaking sensitive information in error messages
  • Consider retry patterns for integrations

Build for performance and scale

  • Minimise Dataverse calls inside plugins
  • Use queries efficiently
  • Avoid processing more data than needed

Deploy via managed solutions

  • Always deploy plugins as part of a managed solution
  • Ensure assembly versions are updated and tracked
  • Use Azure DevOps pipelines to deploy consistently

Summary

Plugins provide a robust and high‑performance way to implement advanced business logic within Dynamics 365. They should be used when configuration or low‑code tools cannot meet the requirement, or when logic must run synchronously and efficiently at scale.