How to call CDS/ Dynamics 365 action from Microsoft flow (Power Automate)

For training and consulting, write to us at info@xrmforyou.com
Follow my blog for more interesting topics on Dynamics 365 and Portals

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. So let’ start with the lightning power of flows.

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.

image

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.

image

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.

image

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.

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

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)

2 thoughts on “How to call CDS/ Dynamics 365 action from Microsoft flow (Power Automate)”

  1. Hi,
    How do you set the contactid for ‘Contact’ entity reference input parameter, as the editor lists all contact fields except the ‘contactid’?

  2. Hi Debajit, I am facing similar issue with one of the unbound actions InstantiateTemplate where it works fine while calling from JS but not flow. Not sure how to resolve this as the unbound action is showing only three available textboxes.

Comments are closed.