Forum Discussion
Pagination with List.Generate, however issues when implementing with empty tables
- 3 years ago
Hi ljaos67 ,
to me this looks as if the [Result] actually never gets null, so you might need to find a different function for the continue-parameter.
But in order to determine what is actually going on, you could add a counter-limit to the parameter first and then check the result of the current/latest iteration like so:
(url as text) as table =>
let
num = Record.ToTable(CustomCmicConnector.Feed(url & "/ap-rest-api/rest/1/manualcheck")){1}[Value],
Query2 = List.Generate(()=>
[Result = try RetrieveAPManualChequeRet(0) otherwise null, Page = 0],
each [Result]<>null and [Page] < 100, // or whatever number falls into that range
each [Result = try RetrieveAPManualChequeRet([Page] + num) otherwise null, Page = [Page]+num],
each[Result]),
#"Converted to Table" =...
Hi ljaos67 ,
to me this looks as if the [Result] actually never gets null, so you might need to find a different function for the continue-parameter.
But in order to determine what is actually going on, you could add a counter-limit to the parameter first and then check the result of the current/latest iteration like so:
(url as text) as table =>
let
num = Record.ToTable(CustomCmicConnector.Feed(url & "/ap-rest-api/rest/1/manualcheck")){1}[Value],
Query2 = List.Generate(()=>
[Result = try RetrieveAPManualChequeRet(0) otherwise null, Page = 0],
each [Result]<>null and [Page] < 100, // or whatever number falls into that range
each [Result = try RetrieveAPManualChequeRet([Page] + num) otherwise null, Page = [Page]+num],
each[Result]),
#"Converted to Table" =...
- ljaos673 years agoFrequent Visitor
For GET requests that contain at least one record and that have many pages, this function works. The function only doesn't work for tables that don't contain any data at all.