CLOSE
CLOSE
https://www.sikich.com

Utilize Dynamics 365 FetchXML Query Generated From a View Within Power Automate

Dynamics 365 FetchXML is a powerful tool for querying data from Dataverse within Power Automate. It allows you to retrieve specific records based on your criteria. In this article, we’ll cover how to leverage Views to create a FetchXML query and seamlessly integrate it into your Dynamics 365 flows.

We will leverage a FetchXML query to get us a list of Enabled Users, who own Active Leads that have not been modified in the past seven days. We will then utilize the generated query in a Power Automate flow.

Understanding FetchXML

FetchXML is a proprietary XML-based query language used to retrieve data from Dataverse. It’s commonly employed for querying records, defining views in model-driven apps, and supporting reporting capabilities.

Using Views to Create FetchXML Query in Dynamics 365

Create Your Query

  1. Start by selecting the Entity you want to query, in this example we will utilize the User entity.
  2. Select the “Edit filters” button on the default view.
edit filters from query
  1. Add Conditions by selecting “Add related entity” and choose “Leads (Owning User).”
add conditions to filter
  1. In the “Leads” criteria, add the condition: Modified by on or before any date. You can further refine your query by adjusting conditions, sorting, and grouping.
add condition to leads criteria

Download

  1. Select “Download FetchXML”
select Download Fetch XML
  1. This will generate the FetchXML representation of your query.

View

Open the recently downloaded FetchXML.

open the recently downloaded FetchXML query from Dynamics 365

Utilizing FetchXML in Power Automate

For this scenario, we want to create an automation that runs weekly and lists Users who own active leads that have not been modified in the past week.

Create a Power Automate Flow

  1. Log in to your Power Automate account.
  2. Click on “Create.”
  3. Choose a trigger. In this scenario, we can select Recurrence and set the flow to run on Mondays every week.
set the flow run
  1. Next let’s add a “Subtract from time” action and set the Base time to utcNow(), Interval to 7, and Time unit to Day. This will help us filter our data later in the flow.
subtract from time action

Retrieve Lead Data

  1. Add an action to retrieve user data. Use the “List Rows” action and select the User table.
use the List Rows action
  1. In the “Fetch Xml Query” column of the automation, add the query and replace the modified on date with the “Calculated Time” created previously.
full Dynamics 365 FetchXML query

Utilizing a Dynamics 365 FetchXML query in your Power Automate flows is an incredibly useful tool to clearly define the records you are trying to work with. Now you can seamlessly utilize your FetchXML query generated from a View within Power Automate.

Have any questions about using FetchXML queries? Reach out to our Dynamics 365 experts at any time!

This publication contains general information only and Sikich is not, by means of this publication, rendering accounting, business, financial, investment, legal, tax, or any other professional advice or services. This publication is not a substitute for such professional advice or services, nor should you use it as a basis for any decision, action or omission that may affect you or your business. Before making any decision, taking any action or omitting an action that may affect you or your business, you should consult a qualified professional advisor. In addition, this publication may contain certain content generated by an artificial intelligence (AI) language model. You acknowledge that Sikich shall not be responsible for any loss sustained by you or any person who relies on this publication.

About the Author