Home > Canvas Apps > [Experimental Feature] Call Dataverse actions directly in Power Fx

[Experimental Feature] Call Dataverse actions directly in Power Fx

In one of my previous articles, I’ve explained the steps to call the Dataverse Custom API from Canvas App using Power Automate cloud flow.

Recently a new experimental feature Call Dataverse actions directly in Power Fx released using which makers can now directly invoke a Dataverse Custom API within a Power Fx formula.

About the feature:

  • Power Apps will support the ability to directly call synchronous Dataverse actions without having to create a Power Automate Flow.
  • For apps that need to call many Dataverse actions, this will provide a significant performance boost.
  • It’ll be much easier to directly call Dataverse actions from the new Power Fx language element Environment.
  • The Environment object allows authors to dot into actions available in the environment. 
  • Its currently an Experiment feature and can be enabled from Canvas Studio -> Settings -> Upcoming features -> Experimental. Turn on the ‘Enable access to Microsoft Dataverse actions’ toggle.

In this article lets learn how to call the Custom API directly in Power Fx formula without the need of Power Automate flow. But first lets get familiar with our Custom API.

Custom API Details:

  • I already have a Custom API by name ‘cat_onboardcustomer‘ (Refer article for steps to create Custom API from scratch).
  • cat_onboardcustomer‘ API has a request Parameter by name ‘cat_customername‘ of type ‘String’.

Now that we know our Custom API, lets learn how to call the API in Power Fx by building a simple canvas app.

Steps to call Dataverse actions directly from Power Fx:

  • Create a Canvas App.
  • Open Settings -> Upcoming features -> Experimental. Turn on the ‘Enable access to Microsoft Dataverse actions’ toggle.
  • By enabling, A new Power Fx ‘Environment’ language object will be available under ‘Data sources’.
  • From the Canvas App, search for the ‘Environment‘ data source as shown below.
  • Double click and add the Environment data source.
  • Add a button on to the Canvas App and ‘OnSelect’ event, write the following Power Fx formula.
    • In the formula, we are calling cat_onboardcustomer API using ‘Environment’ data source.
    • We are also passing cat_customername request parameter in json format.

Environment.cat_onboardcustomer({cat_customername: "Calling API from Power Fx is awesome"})
  • That’s all needed. Play the App and click the button and you should see the ‘Account’ created with the name “Calling API from Power Fx is awesome”.

🙂

Categories: Canvas Apps Tags: ,
  1. No comments yet.
  1. March 3, 2023 at 4:22 PM

Leave a comment