jatomas.com - Power automate & MSDyn365FO: Deep dive (IV)

Power Automate & MSDyn365FO: Deep dive (IV)

A few weeks ago, preparing the session for the Global Power Platform Bootcamp 2021, I realized that the series of posts that I had written about Power Automate & MSDyn365FO was incomplete…, I hadn’t analyzed one of the options availables on the Dynamics 365 Finance and Operations apps connector: Execute action

Execute action

From execute action option we have the possibility of executing X++ code that we expose through the Dynamics 365 F&O data entities. Exposing OData actions through these is pretty straightforward, let’s see an example.

I’ve created a test data entity that contains the CustGroup table as data source. Now, we are going to create a method to get the description of the customer group given its code. As you can imagine, it is a fairly simple code.

Once the method is created, all we need to expose it as an OData endpoint is to decorate the method with the SysODataAction attribute, indicating the name we want to give to the action, and if this action is an instance method or not.

Now, we just have to consume the action from a Power Automate flow, which is quite simple.

Power Automate – Execute action

As always, we start by indicating the Dynamics 365 Finance and Operations instance on which we want to execute the action, which will allow us to later choose the specific action we want to execute.

Power Automate – Execute action – Parameters

Once we have selected both the instance and the action (Entity-Action), Power Automate obtains the parameters we need to be able to execute it using the MetadataService service. As you can see in the screenshot, the parameter appears with the exact name that we have written in the method (_custGroupId).

Finally, we just have to indicate the Customer Group and run the flow to see if it works correctly.

After being executed, we can see how the flow obtains the name or description of the customer group that we have indicated in the parameter.

Power Automate – Execute action – Execution results

We are going to consult the IIS log to verify that, as we can imagine, what it is doing is a POST call on the CustGroupName action (name that we indicate in the SysODataAction attribute) of the AXZTests entity.


As is has happened in other actions, the code is also executed on the company associated to the user in the user options, but remember that this time we are executing X++ code directly, so we have greater flexibility . If we need to execute these actions in different companies, we could, for example, add the company code to the parameters of the action, and play with the changeCompany within it. Problem solved! 😎

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Uso de cookies

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información. ACEPTAR

Aviso de cookies