Calling actions from Microsoft flow is now just a cakewalk. All you need to is to use the Common Data service (Current environment) connector introduced in flow. This is not to be confused with the Common data service connector which is there for quite sometime now. If you are not accustomed to this connector, I suggest to refer my previous article on this.
P.S – In this article I am going to show you on how to call a custom action. However you can call any action provided by the system as well.
In this article I am going to show you on how to invoke an action using flows. And for this sample I have taken up an action which has a simple as well was complex input and output parameters. Below screenshot for reference.
As you can see there are two input parameters of type integer and entityreference and two output parameters of type string and entitycollection respectively. The entity reference input I have set it type ‘Contact’
I went ahead and created a flow. For this demo when an account record is created, I will be invoking my action which is unbound (not tied to entity).
Since my action is unbound, I use the “Perform an unbound action” action step in the connector. If you have an action tied to entity, you should use “Perform a bound action” step.
When you try to set the values of Input arguments, the editor will show you the required input types. Since I have kept the entity reference input argument as type ‘Contact’, it shows me the contact input fields.
You can set the input values accordingly and your action would work just fine.
An observation here.
Using EntityCollection as the output parameter may not work. This is because when you set output parameter of type EntityCollection, the action would need an output of type Array. If you use EntityCollection as output parameter, you would get an error similar to the one below.
The API operation ‘PerformUnboundAction’ requires the property ‘body’ to be of type ‘Array’ but is of type ‘Object’.
The solution to the above would be to serialize the entitycollection to a string and returning it as string json as the output parameter. And then use parse json in the flow to get the results.
Our product offerings:
Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)
CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)
Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)
Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)