Reference: 1
As a part of the Power Fx language, authors can now directly invoke a Dataverse action within a formula. Both unbound and bound actions are supported. Authors can add a Power Fx Environment
language object to their app and access Dataverse actions.
Authors can work with untyped object fields for both inputs and outputs. On the input side, for instance, many Dataverse actions require an untyped object as an argument. Authors can now pass these arguments in by using ParseJSON to convert a Power Fx record into an untyped object. On the output side, for actions that return untyped objects, you can simply dot
into returned objects properties. You need to cast specific values for use in specific contexts for use in Power Apps such as a label.
Without this feature, it was common for authors to use Power Automate to call Dataverse directly. However, calling Dataverse directly from Power Fx provides significant performance benefits (and ease of use) and should be preferred for direct transactional reads and updates. If you have an app that uses Power Automate to call Dataverse actions, you see a banner suggesting you use this direct action approach instead.
Working with untyped fields isn't restricted to Dataverse. It works for all types of connectors and provides basic ad-hoc dynamic schema support.
Note
- We do not fully support DV actions in Power Fx commanding (specific to any actions call with parameters.)
- We do not support direct references to an Entity or an Entity collections.
- For parameters of object type that are nested (2 or more levels deep), the second level attributes are treated required in PowerApps.
Enable access to Microsoft Dataverse actions
For new apps, this feature is automatically enabled. For apps created previously, you need to enable access to Dataverse actions.
For older apps, open your canvas app for editing and navigate to Settings > Upcoming features > Retired and enable Dataverse actions.
Add the Power Fx Environment language object to your app
To use Dataverse actions in your Power Fx formulas, select Add data and search for Environment and add it to your application.
This adds the Power Fx Environment
language object to your application.
Accessing Dataverse actions
When the Power Fx Environment
object is added to your application, you can access Dataverse actions by adding Environment
to your formula and then dotting into the actions.
Unbound Dataverse actions are peer level to tables and need the parenting scope of the Environment language object. All actions in your environment are available – both system level and custom. Both bound and unbound actions are available. The 2-level call limit was removed.
For more details on how to use Dataverse actions in your formulas, see Working with untyped and dynamic objects.
Passing Entity type arguments for bound/unbound actions
To pass entity type arguments for Dataverse actions, start by setting the entity type argument value to a variable. Additionally, ensure that any missing values such as *activityId are filled in. This is particularly important for entities that do not have defined types in the swagger.
Set(MyArgVar, {
name: first(systemUser).name,
Id: First(systemUser).Id
... })
Rename, refresh, and actions in other environments
You can rename an Environment by choosing the ellipses and selecting "Rename". If you add a new Dataverse action in Dataverse and need Power Apps to see it, you can choose "Refresh". And, if you need to use an action in a different environment you first need to change the environment and then once there, search for 'Environment', select and add it to your application.
No comments:
Post a Comment