Creating a flow to trigger on-demand from the ribbon in Dynamics 365 CE seems simple to make. But don’t be fooled, it doesn’t seem that simple. Let me guide you through some of the pitfalls I discovered while implementing a flow from a ribbon.
You have two ways of creating the flow for our purpose. First, you can browse via the flow portal to the templates and select “start from data source”. This will show following window:
Pick the first template named “Common Data Service Button”. It will ask for the connection you want to use to build the flow with and press continue.
You can also start from a solution and press new > flow. Pick the common data service connector and choose for the “When a record is selected” trigger.
STOP RIGHT THERE! The only option which will work and shows up is the flow which is not part of a solution. It is very important to be aware of this first takeaway. This has as consequence that you need to manually export/import this flow to different environments. Also a third (but actually second) option to create the flow is to start from the model-driven application in CE and press the create a flow button. It will take you to the same wizard when you started from a template.
Another takeaway is to really think which attributes from the current record you will need. In my experience, when I run the flow for testing purposes and afterwards I want to consume an extra attribute/field from the triggerbody (so for the record on where the button is clicked), the flow will not be able to be executed anymore. You will receive a fault exception that the definition of the trigger has been changed. And this is true! By consuming extra info from the trigger, the required input parameters changed. Seems like Dynamics CE doesn’t do this updating quite well, making your flow useless.
My advice and workaround on this nasty error is the following:
Fetch the whole record based on it’s id. To make this work configure it before you run or trigger the flow. If not, the trigger will get registered in CE without the required record id passed.
I’m pretty sure Microsoft will tackle the issue of the flows not showing up which are in a solution and also the input parameter update registration. Keep an eye out on the frequent releases in their release notes!