Introduction:
In few scenarios when working on List of records for a given entity, we must provide paging to perform certain operations. In order to achieve this, we use different actions in Dataverse and power automate like do until, List Rows, Scope, Initialize, Increment and Set Variables . As an example for contacts entity with the help of changing page number dynamically with logic we can achieve this functionality.
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.

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.

Step 3:
After Step 2, name the flow as Simple Paging With Fetchxml add a new action Initialize Variable and name it as Initialize variable – Page Number and provide the following inputs
Name : Page Number
Type : Integer
Value : 1
as shown in the below figure.

Step 4:
After Step 3, take another action and name it as Do until and under condition provide the inputs as
Condition: variables(‘Page Number’)
Operator : is equal to
Value :0
as shown in the below figure.

Step 5:
After Step 4, under Add action select Dataverse-> List rows and select the following values as inputs
Table name : Contacts
FetchXmlQuery:
<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”false” page=”variables(‘Page Number’)”>
<entity name=”contact”>
<attribute name=”fullname” />
<attribute name=”telephone1″ />
<attribute name=”contactid” />
<order attribute=”fullname” descending=”false” />
</entity>
</fetch>
as shown in the below figure.

Step 6:
After Step 5, take a Scope action and under that add condition component with inputs as
Condition : length(outputs(‘List_rows_-_Contacts’)?[‘body/value’])
Operator: is greater than
Value: 0
And under if yes part take Increment variable and name it as Increment variable – Page Number and provide inputs as
Name : Page Number
Value : 1
And under if no part take Set Variable and name it as Set variable – Page Number to 0 and provide inputs as
Name : Page Number
Value : 0
as shown in the below figure

Step 7:
After Step 6, save and test the flow by selecting manual option and see the result for the first page and second pages as

And in the second page looks like

Note:
- Make sure to save and run the flow whenever you try expressions.
- Here I have 3 contact records in the contact table.
- If you don’t handle list properly it leads to infinite loop for paging.
Conclusion: In this way one can get simple paging with FetchXML on Lists in Power Automate with simple logic.
Thanks for sharing, do you have any similar blog posts on how to perform a bulk update for more than 100K records by using the paging, and batch functionality? Hence, the flow should be designed in a way to avoid hitting the service protection API limit (6000 within the 5 minutes sliding window). What can be the strategies for working within these restrictions?
LikeLike
See as per me with that huge amount records , Azure Function+ Logic Apps will be scalable.
LikeLike
Pingback: Rewind January 2022 – Common Man Tips for Power Platform, Dynamics CRM,Azure