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

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.

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)

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s