Power Automate List Rows In A Dataverse View
Power Automate can be used to list the rows in a Dataverse view. Views are a saved query which can select specific columns, filter based upon a set of criteria, and sort the results. The best part is you can configure them with no coding knowledge required. Then it’s possible to use the Dataverse view in a Power Automate flow.
Table of Contents
• Introduction: The Redmond Accounts Automation
• Create A Dataverse View For The Accounts Table
• Download Fetch XML For The Dataverse View
• Include Fetch XML In The Dataverse List Rows Action
• Run The Power Automate Flow To Get A Dataverse View
• Get Dataverse View In Power Automate Using The View Name
• Test The Power Automate Flow To Get A Dataverse System View
Introduction: The Redmond Accounts Automation
A Dataverse view named Redmond Accounts is found in the Accounts table within a model-driven app. The view to shows only Accounts having a city of Redmond.
A Power Automate flow uses the view to get the same list of rows as the view.
Create A Dataverse View For The Accounts Table
We need to setup a new system view to call from a Power Automate flow. Go to the maker portal, open the Tables menu and select the Account table.
Create a new view named Redmond Accounts.
Include the following columns and then select Edit Filters:
- Account Name
- Address 1
- Address 1: City
- Address 1: ZIP/Postal Code
Apply the following filters, press OK, then Save & Publish the view:
- Address 1: City = Redmond
- Status = Active.
Download Fetch XML For The Dataverse View
Dataverse views use a query language named Fetch XML. We can use a query’s Fetch XML in a flow to get the same results. Open the Accounts table within a model-driven app, select the Redmond Accounts view, and then go to Edit Filters.
Download the FetchXML.
The Fetch XML output looks like this. We will use the Fetch XML in the List Rows action of our Power Automate flow.
Include Fetch XML In The Dataverse List Rows Action
Create a new instant flow named List Rows From A Dataverse View.
Add a Dataverse – List Rows Action to the Power Automate flow. Select the Accounts table and copy & paste the Redmond Accounts Fetch XML into the Fetch XML Query field.
Then add a Compose action with the value of the List Rows action so we can view the query results.
Run The Power Automate Flow To Get A Dataverse View
We’re done building the flow. Test the flow to ensure it works.
The flow outputs all of the rows from the Redmond Accounts Dataverse View.
Get Dataverse View In Power Automate Using The View Name
An alternate way to get the list of rows in a Dataverse view is to lookup the query name in Power Automate and fetch the results. The benefit of doing this is the flow will be automatically updated when the query is changed.
To do this, add an HTTP With Microsoft Entra ID (preauthorized) – Invoke An HTTP Request action to the flow.
Input the following URL for the Base Resource URL and Microsoft Entra ID Resource URI.
https://org7df81c35.api.crm3.dynamics.com
Then add a Dataverse List Rows action and a Compose action to the flow as shown below.
Choose this method in the Invoke An HTTP Request action.
GET
Use this url of the request.
api/data/v9.2/savedqueries?$filter=name eq 'Redmond Accounts'
And fill-in the Fetch Xml Query parameter of the List Rows action with this flow expression.
first(body('Invoke_an_HTTP_request')?['value'])?['fetchxml']
Test The Power Automate Flow To Get A Dataverse System View
Run the flow once more to verify it completes successfully.
Rows from the Redmond Accounts Dataverse view are fetched from the Accounts table.
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps & Power Automate articles sent to your inbox each week for FREE
Questions?
If you have any questions or feedback about Power Automate List Rows In A Dataverse View please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.
Instead of adding yet another connection reference by using the HTTP request to get the system view’s data, you can also just use a List rows action to query the savedqueries table, setting the columns to fetchxml and the filter to name eq ‘[view name here]’
The rest of the logic is the same as when using the HTTP request.
Hi Matthew.
Can you elaborate where this needed. I’m presuming you are processing the output (for each) to do something else. Also, once again using hard coded URL for the org(grrr). Yes, I’ve seen ways to extract that but it’s about time MS gave us single liner for it. I’m sure there are cases where you may wish to run a flow without interaction (eg every day etc). What other uses would this process be useful for? The of needing hard code URL as I said need to be fixed. I’ve seen where flows have been run against the wrong Env because of it.
Pete
Peter,
After posting this article a reader informed me that we can use the Dataverse table named “Views” & a List Rows action to get the same result as the Invoke An HTTP request method. I will be revising this blog post later in the week to show that method instead 🙂
Instead of hard-coding URLs, you should use environment variables of the type text. I always create them for the first part of the URL (https://whatever.domain.tld) and append that as needed in the flows. If the main URL changes, it’s a single edit for all flows it’s used in and if there are different URLs per environment, I set the ‘default’ value to that of the production environment and use the ‘current’ value for the other environments.
Just my $0.02 🙂