Dropping new goodies straight to Microsoft Docs, without any formal announcement, has now been normalised. Couple of Virtual Table features have been “announced” without much fanfare this way. The ability to trigger Flows from Custom API is one such unannounced feature.
Custom API is a feature in Dataverse that is very similar to Custom Process Actions (formerly known as Actions). You can refer Compare Custom Process Action and Custom API doc to understand the differences. There are many useful tools to help you work with Custom API in XrmToolBox. They are
- Custom API Manager by David Rivard
- Custom API Tester by Jonas Rapp
- Custom Action to Custom API Convertor by Mark Carrington
The UI to create a new custom API is a bit to many clicks. So, we will use Custom API Manager to create our API and Custom API Tester to trigger it. You can easily create a new Custom API using Custom API Manager.
The important points to note when you create a Custom API that can be used as trigger are:
- You cannot have the IsFunction set to true
- You cannot have IsPrivate set to true
- You cannot have Allowed Custom Processing Step Type set to None
After you have created your Custom API, you need to create
- Root Catalog
- Atleast one Child Catalog
- One Catalog Assignment record for each Custom API or Table
- You cannot add Catalog Assignment records straight to the root catalog
You can do these right inside the solution. Here is how my root catalog record looks like.
The unique name of the catalog needs to have a publisher prefix, otherwise you will get this error.
After creating the root catalog, you can create the child catalog from the related records area in the form.
This is how my child catalog looks like
I am going to add all my Custom APIs to this Custom APIs sub-catalog as Catalog Assignment. You can add both Custom APIs and Tables/Entities (if the Custom API is bound to an Table) from this screen.
Here is how my solution looks like after creating Catalog, Custom APIs and Catalog Assignment records.
Next step is to create the Flow with the “When an action is performed” trigger. In this trigger you need to choose the Root catalog, the sub-catalog and the custom API in that sub-catalog.
If the Custom API is bound to an Table, you need to choose the Table and then the Custom API, as it filters down the Custom API by Table.
Here is how my trigger looks like. Since my Custom API is not bound to any entity, I choose none for the Table name.
My Flow will now run when I trigger the Custom API. I can do this using Custom API tester.
I can also trigger the Custom API from Flow itself.
This will cause trigger my Flow that was waiting for that Custom API call.
One thing to note is that you created the custom API with Is Private set to true, you will still see that custom API in the Flow trigger, but when you save the Flow, you will get this exception.
One word of warning: This is a preview feature. So, don’t use it in production yet. This is a welcome feature, and it opens up Flow to more integration scenarios.
- Trigger flows when a Microsoft Dataverse action is called
- Catalog and Catalog Assignment Tables (Thanks to Jim Daly for sharing this docs link)