This is the second in the series, so make sure you read the 101 blog first.
Functions in Dataverse and Low-Code Plug-ins are the same and not the same. In the future everything may be in Functions in Dataverse, but as on writing Automated Plug-ins are only in the Dataverse Accelerator.
- What Are Automated Plug-ins
- How to Create one
- The Code
- Bugs
- Quick Example
1. What Are Automated Plug-ins
Automated plug-ins, I suspect are the future replacement of Business process.
Business Process add logic to a Dataverse table beyond a simple calculated column. They can do validation, conditions, update other tables, trigger flows, etc.
So a Automated plug-in is linked to a Dataverse table, and on an event (Create, Modify, Delete), the script will run. As by the name, you may have guessed this script uses Power FX, the same language in Power Apps and calculated columns.
2. How to Create one
After installing the Dataverse Accelerator app go to make.powerapss, and view all Apps, you should see the Dataverse Accelerator App
Open the Model Driven app and you will see 4 options:
- Create instant plug-in (next blog)
- Create automated plug-in (that's the one)
- Plugin monitoring - run history of all plug-ins
- API Explorer - test Dataverse API's, including instant plug-ins
Click on Create automated and you will see the build screen
There are the following inputs:
Display Name
Your Plug-in, this is also its unique name, so cant have the same name as another plug-in (unlike Apps and Flows).
Table
This is the table that the plug-in is linked to, so interactions with it trigger the plug-in and all internal referenced functions are to this table.
Run this plug-in when the row is
What interaction with the table triggers the plug-in, Created, Updated, Deleted. Unlike Power Automate flows you can only select one, not multiple.
Expression
This is the main coding input where the Power FX code is
When should this run
This is when the code should run, Pre-operation will run after validation of the inputs but before the data is written to the table, Post-operation runs after the data has been written to the table.
Solution
Low-Code Plug-ins are solution aware, so can be added to a solution for ALM. Although you can add the plug-in to a solution later, by selecting here it is not only added but inherits the solutions publisher prefix.
Once created the only way to test is to trigger by a table interaction (no reruns like in Power Automate).
3. The Code
As there are no direct inputs or outputs like in Instant, all code runs internal, with data flowing in and out from the linked table, any other Dataverse table, or Connection.
To reference the linked table you use 'NewRecord', as 'ThisRecord' is used for filters/lookups etc.
You can also use more advanced functions like filter etc,
In the above example the filter is on the linked table, but it can be any table (within the environment, there is no cross environment support).
You can also add validation by using the Error() function.
This is where the Pre-operation setting is important, as this will stop the record being written if it errors, while post will create the record and then flag as error.
To add the super power of Low-Code Plug-in's (Connections), click the Connections button in the top right of the screen. Here you will see a list of all of your connection references.
Once the reference is selected you will see all of the actions you see in Power Automate. Select and click the Copy to add the action to your clipboard, then paste in your code.
The parameters follow the same as in Power Automate and Power Apps, so if you remember them just follow the same order. But to make it a lot easier we have intellisense, this will show you the parameters needed.
Now whenever a error is created the record is still added but sends an email.
4. Bugs
In 101 I did say that a lot of bugs had been fixed, but sadly not all. There are still lots of issues, especially with connectors.
Although Outlook works, SharePoint not so much. In Automated I always get errors "unknown or unsupported function in namespace {connectionRefName}" errors. It states it implies its a connection reference issue, but its not as its with all connections. In Instant plug-in's I don't always get it, but then there are more issues (see next blog).
I will also get the same error occasionally with Outlook, but if I copy the code to a new Plug-in it works.
The sad thing is with Functions in Dataverse not doing non Dataverse Connections, the deprioritizing of Low-Coding Plug-ins, and the lack of Copilot being involved, its unlikely these bugs will be fixed anytime soon.
5. Quick Example
As these are embedded with Dataverse they add a lot of functionality to Model Driven apps.
A quick and cool example is in App notifications. As long as you have enable in App notifications you can use the XSendAppNotification() function in your plug-in.
Then as soon as the event is triggered it will notify the user in the app (in my case its whoever modified the record, but it could be the owner or anyone).
I have at least one follow on blogs coming over the next few weeks going into more detail abput instant plug-ins. Subscribe below if you want to be notified (or click the links if you are reading this in the distant future).
Top comments (3)
I thought low-code plugins weren't supposed to be used as they're being replaced by functions?
Low-code plug-ins have been deprioritized, so eventually I Suspect so. But there is a massive feature gap they can't, as in functions can't be automated at the moment so you have to use plug-ins. Check out previous blog in the series, goes into more detail on it
Totally agree...pretty silly when they basically tell you not to use something that offers critical functionality and give a replacement that's very much still WIP