If you want to retrieve more than 5,000 records in a Flow using List Rows action from Dataverse, you need to page through the records. Flow does not automatically do this for you. This is not a new topic. It is already been explored by Linn and Debajit. You can read their posts below:
- Linn – https://linnzawwin.blogspot.com/2021/01/retrieve-more-than-100000-dataverse.html
- Debajit – https://debajmecrm.com/how-to-query-more-than-5k-cds-records-using-fetchxml-in-powerautomate-microsoft-flow/
When I was looking into this same problem, I used two things differently:
- Using interationIndexes for paging
- Using xml for encoding paging cookie, instead of manually encoding “<” to “<”, “>” to “>” etc.
Here is the Flow

I use iterationIndexes like this for the page for each iteration.

The paging cookie returned in the first page looks like this
<cookie page="1"><systemuserid last="{7A44238F-9894-EB11-B1AC-002248153EDE}" first="{5C4D8EE8-62FF-E911-A811-000D3A799417}" /></cookie>
I then use the expression below to sanitise the characters so that I can use it in the subsequent page. It looks a bit clunky and verbose, but the key thing here is that when xml function to encode the XML, it also sanitises it. encodingJSON is a temporary object used to store the paging cookie XML. This JSON is what gets converted to XML and cleaned up with split and substring.
if(equals(iterationIndexes('Do_until'),0),
'',
concat(
'paging-cookie=''',
substring(
first(
skip(
split(
string(xml(setProperty(variables('encodingJSON'),'x',variables('pagingCookieCleansed'))))
,'<')
,1)
)
,2),
'''')
)
Here is the Flow running through all pages.

You can download this sample Flow from https://1drv.ms/u/s!AvzjERKFC6gOx3ZbdK8YOBYat0CV?e=M41ONd
[…] Muista kuitenkin että Fetxh XML:ää hyödynnettäessä flow’n toiminto palauttaa max 5000 riviä. Mikäli tarvitset enemmän, joudut rakentamaan sivutuksen itse. […]