Microsoft Flow is new and amazing product that allows to build different automations without opening Visual Studio. Components for Dynamics 365 for CE/CDS are limited at the moment. It’s possible to start flow either on-demand or when record is created/updated/deleted inside system and it allows to create/update/delete records and retrieve sets of records and iterate through it. But Dynamics 365 for CE has more possibilities available so in my post I’ll provide step-by-step instruction how to call actions/functions from Flow. I my post I will use WinOppotunity action as an example.
Building proper WebApi request
To build and test WebApi request I highly recommend to use Postman application. There are many excellent posts that describe how to configure Azure AD, Dynamics 365 for CE and Postman so I’ll just leave references to posts that helped me with setting it up:
Posts from “SMS Management and technology” blog are not available now so I can’t provide urls (or I’ll do it once blog is restored).
Here is result that you should get:
Save your request into collection and export it using “Collection v1 (deprecated)” option and save it somewhere:
Registering Azure AD Application for Flow
Open Azure Portal -> Azure Active Directory -> App Registrations -> New application registration:
Enter Name (Flow Custom Connector in my case), choose “Web app/API” in Application Type and enter any valid Url into Sign-on URL (I used http://localhost) and click Create:
Copy “Application ID” and save it somewhere:
Open “Setting” -> “Required Permissions” -> “Add” and add “Dynamics CRM Online”:
After this your “Required Permissions” tab should look like following:
Now create a key for your application – open “Settings” -> “Keys” -> enter name of new key and expiration date, click Save and copy and stave somewhere value from “Value” column immediately because it will not be shown again:
Adding Custom Connector to Flow
Open Flow portal and choose “Custom Connectors” from menu:
In window that appeared click “Create custom connector” -> “Import a Postman collection”:
Enter some name into “Custom connector name”, click “Import” button and choose json file you got when you exported Postman collection in first part of this post, click “Continue”:
If you did everything the right way you will be redirected to new connector configuration “General” page. You can change some additional information there like icon, icon background color or description. Once you finished with changes click on “Security” to navigate to the next configuration page.
In authentication type choose “OAuth 2.0”, inside Identity Provide choose “Azure Active Directory”, populate “Client Id” and “Client Secret” with values from previous part, leave “Login Url” and “Tenant ID” as it is. Put url of your D365CE instance to “Resource URL”, leave scope as it is and go to the next page – “Definition”:
Inside definition you can configure how yours custom connector will look like in Flow designer (including representation of request and response):
Once you finished with “Definition” click “Create connector” button before testing it. Once connector is created go back to “Security” and copy value from “Redirect Url” at the bottom of page:
Now go back to Azure Portal and your “Registered App” – Settings – Reply Urls and add your “Redirect Url” to it:
And now it’s time to test connector – go back to “Flow” portal and navigate open “Test”. Click “New connection” to connect to D365 for CE instance. If you configured everything in the right way on “Azure” side you will get connection:
Compose your request using example data you used to test your requests in Postman:
Click “Test operation” button and if everything is ok you should see something like following:
Let’s check how it looks like in D365 for CE:
Usage of custom connector in Flow
Thanks for wonderful post.
With the latest updates we can directly call Actions from Flow . Please refer to link https://www.inogic.com/blog/2019/11/how-to-call-an-action-through-power-automatems-flow/