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
- Start by selecting the Entity you want to query, in this example we will utilize the User entity.
- Select the “Edit filters” button on the default view.
- Add Conditions by selecting “Add related entity” and choose “Leads (Owning User).”
- 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.
Download
- Select “Download FetchXML”
- This will generate the FetchXML representation of your query.
View
Open the recently downloaded FetchXML.
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
- Log in to your Power Automate account.
- Click on “Create.”
- Choose a trigger. In this scenario, we can select Recurrence and set the flow to run on Mondays every week.
- 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.
Retrieve Lead Data
- Add an action to retrieve user data. Use the “List Rows” action and select the User table.
- In the “Fetch Xml Query” column of the automation, add the query and replace the modified on date with the “Calculated Time” created previously.
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.