Problem
If you’ve been building solutions with Power Platform, you’ve probably hit some frustrating limitations. Tasks that should be straightforward, like generating barcodes or QR codes, splitting and merging PDFs, hashing and decoding strings, or converting numbers to words, often can’t be handled natively.
In these cases, you’re usually forced to rely on third-party APIs or connectors. That means not only paying for Power Apps or Power Automate Premium, but also for those external services – and that cost can add up quickly. It feels a bit unfair, right?
But what if I told you there’s a way to handle all these operations directly within Power Platform, without the need for expensive third-party solutions? Yes, it’s possible!
Solution
Meet Custom Plugins – a powerful feature of Microsoft Dataverse that lets you extend the platform with custom C# code. Once deployed, these plugins can be seamlessly executed from both Power Apps and Power Automate, giving you total control over your solution’s logic.
It’s similar to using third-party APIs, but with a crucial advantage – everything runs within your Dataverse environment, fully secured under your Microsoft 365 tenant.
This means no more sending sensitive corporate data to unknown external services, and best of all, there are no extra charges. You only need Power Apps or Power Automate Premium, without any additional third-party costs.
Prerequisite
There are few prerequisite before you can create custom plugin.
- Power Platform environment (with Dataverse)
- You must be System Administrator or System Customizer role, in the target environment
- Microsoft Power Platform CLI
- Plug-in Registration tool (Already included with Power Platform CLI)
- Visual Studio (2019 or newer)
- Knowlege of C#
- I’ll be real – I’ve never actually learned C#. Sure, I can code, but C# isn’t in my usual toolkit.
- But hey, We’ve got generative AI on our side. Whether it’s ChatGPT, Copilot, Gemini, Claude, or whatever AI assistant you prefer, you’ve got all the help you need to write that C# code.
Create your first plugin
Alright, let’s break this down step by step and build your plugin from scratch.
There are a few ways to tackle this, but trust me – I’ll walk you through the simplest approach, one that even someone with zero C# experience (like me) can handle.
Disclaimer: I’m not a C# expert, so this guide won’t dive deep into C# coding. Instead, the focus here is on how to create custom plugins for Microsoft Dataverse.
1. Install Visual Studio
Download and install Visual Studio
Make sure you include .NET desktop development workload during the installation.

2. Initialize plugin using Power Platform CLI
Create empty folder to store our plugin project.

Open cmd and then navigate to folder. Then type the following command and hit enter (Make sure you have Power Platform CLI installed).
pac plugin init --skip-signing

This will create all things we need to create custom plugin.

3. Open project in Visual Studio
Let’s open Visual Studio and select ‘Open a project or solution‘.

Then navigate to our folder and select .csproj file (This was created by Power Platform CLI)


4. Create new class for our plugin
Assume that each .cs file = 1 plugin, So, we will create new class.

You can enter any name you want, but for this tutorial, I will create plugin that use to generate barcode / QR code so I will named it ‘GenerateBarcode.cs’


We will get new class and now it’s time to code!
5. Let’s (vibe) code
I’ll be honest – this part is the toughest for me. As I mentioned, I don’t have any C# experience, and I wasn’t even sure where to start.
So, I’ll be leaning on generative AI to handle the heavy lifting. In my case, I’ll use ChatGPT.
Just explain the function you want for your custom API, but make sure to mention that it’s for a Dynamics 365 custom plugin. That context is crucial.
You can even copy the code from Plugin1.cs and paste it into ChatGPT to give it a head start.


Most of the time, you’ll want to use libraries to avoid reinventing the wheel.
If your code relies on external libraries, you can easily add them through the NuGet Package Manager.


And all required package, fixing error then go next step
(This step may require pro-code knowledge because sometimes code from ChatGPT will doesn’t work at first attempt)
6. Spot your output and input
Like any API, your plugin will need both inputs and outputs. If you check the code, you’ll see that these are already defined.
Make sure to take note of each input and output, as you’ll need to specify them in a later step.

7. Build / create plugin package
After you’ve done all coding things, Now you need to build. The build operation is to complie all the code and make them to single package file.

The build operation will produce .nupkg file, You will need this file in later step.

8. Register plugin
Now its time to register our plugin to Dataverse.
Open cmd then type following command and hit enter to open Plugin Registration Tool (PRT)
pac tool prt

This will open PRT interface.
Click ‘Create new connection‘ to establish a connection to your Dataverse environment

Wait it load for few seconds, then click on ‘View‘ -> ‘Display by Package‘

Click on ‘Register‘ -> ‘Regiser New Package‘

Select your .nupkg file for Plugin package file (You can select Solution for storing the package if you want)
Then click ‘Import‘

If the import was success, you will see your package is now listed in the window. Which mean your code has been deployed to Dataverse.

9. Register Custom API
Next, we need to create something called a Custom API, because we can’t directly invoke the code in our C# class.
First, we need to bind the C# code to this Custom API.
Click on ‘Register‘ -> ‘Register New Custom API‘

Fill all the details, then select your package for Assembly and select your class name for Plugin.
Now you will need to specify Request Parameters which mean Input and Response Parameters mean Output, this need to match with one defined in the code

IIf you want to restrict access to your Custom API to specific users, you can use privileges to control who can invoke it. Click for more information
Finally, click ‘Register’ to complete the registration process
10. Test & execute your plugin
It’s time to test our plugin, We can use Power Automate to do this using action ‘Perform an unbound action’ from Dataverse connector.
You will see your Custom API name listed under Action Name. Populate all the required input with desired data.


For Power Apps, you can add table named ‘Environment’ to your app and use formula just like the image below to execute your Custom API.
