List Contacts Based On FetchXMLQuery In Power Automate

Introduction

During certain scenarios, we must work on a List of records to perform certain operations like sending alerts to a list of customers. In these scenarios, it is critical to filter records to make sure actual requirements was met. In Power Automate, we can use FetchXMLQuery option under List Rows as an example we can see list of contacts in an environment.

Step 1

Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and click on Flows on the left-hand side as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Step 2

After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Step 3

After Step 2, name the flow as List Contacts Based on FetchXmlQuery take another step under Dataverse Connector, select List Rows action and name it as List rows - Get Contacts and provide the following inputs

Table name : contacts
Fetch Xml Query:
<fetch top="50" >
    <entity name="contact">
        <filter>
            <condition attribute="cr5bc_vaccinationcompleted" operator="eq" value="1" />
        </filter>
    </entity>
</fetch>

as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Step 4

Before Step 3, you can get content of fetchxml query by going into advance find in classic interface of CRM and select contact record and then keep a filter on Vaccination Completed and download fetch XML as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Step 5

After Step 3, take Create HTML Table action and form Header and Value with custom columns option as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Step 6

After Step 5, save flow and run the flow and you should see filtered contact records as shown in the below figure.

List Contacts Based on FetchXMLQuery in Power Automate

Note

You can observe 200 as status reason for List rows – Get Contacts step as shown in the below figure

List Contacts Based on FetchXMLQuery in Power Automate

Make sure to keep enclosed body part of list table inside [] array in Step 5.

Conclusion

In this way, we can easily filter data in List rows with fetch XML in Power Automate.