Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

PCF Model Driven App - Not all records are loaded (Dataset)

(0) ShareShare
ReportReport
Posted on by 87

Hey.

 

It seems that some of the properties in the dataset, is not behaving the way i would think.

 

1:  context.parameters.dataset.paging.totalResultCount is sometimes showing -1 (Is this property even supported?, it is in the typescript definitions)

 

2: Randomly, dataSet.paging.hasNextPage is undefined, while dataSet.loading is false, but all the records is not loaded into the dataset yet.

 

3: Sometimes, dataSet.paging.loading is true, but all records are in the dataset (create unnecessary extra dataload)

 

 

I have created this test script:

 

I have a view with 15500 records, and 15-20 % of the time, not all records are loaded into the dataset, am i missing something here?

 

 

 

 

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement) {
 this.container = container;
 var dataSet = context.parameters.Tasks; 
 if (dataSet.paging.totalResultCount > 0)
 dataSet.paging.setPageSize(dataSet.paging.totalResultCount);
 else dataSet.paging.setPageSize(5000); 
 }

 

 

 

 

 

 

 

 

 public updateView(context: ComponentFramework.Context<IInputs>): void {
 var dataSet = context.parameters.Tasks; 
 
 
 //Debugging
 if (dataSet.loading) {
 //If we know the totalResult, we can check if all are loaded
 if (dataSet.paging.totalResultCount > 0) { 
 if (dataSet.sortedRecordIds.length != dataSet.paging.totalResultCount) {
 console.log("Length not same as totalcount",{...dataSet})
 return;
 }
 console.log("Length same as totalcount",{...dataSet})
 }
 //If the total result is unknown, we need to return to ensure all is loaded
 else {
 console.log("resuultCountUnknown",{...dataSet})
 return;
 }
 
 } 
 else {
 console.log("Dataset not loading",{...dataSet})
 console.log("Has next page:", dataSet.paging.hasNextPage )
 
 }

 //if data set has additional pages retrieve them before running anything else
 if (dataSet.paging.hasNextPage ) { 
 console.log({...dataSet}) 
 dataSet.paging.loadNextPage();
 this.count++;
 console.log("Load count", this.count);
 return;
 }
 
 console.timeEnd("dataload");
 console.log("Count",this.count); 
 alert(dataSet.sortedRecordIds.length); 


 ReactDOM.render(React.createElement(App, { context }), this.container);
 }

 

 

 

 

  • Verified answer
    Kristoffer88 Profile Picture
    87 on at
    Re: PCF Model Driven App - Not all records are loaded (Dataset)

    This was a error on our tenant. There was a onFormLoad script, that called Xrm.Page.data.refresh(true) after a call to update some rollup fields.

  • Kristoffer88 Profile Picture
    87 on at
    Re: PCF Model Driven App - Not all records are loaded (Dataset)

    Thanks for the reply Diana.

     

    The problem i am seeing, is that i cannot trust the loading and hasNextPage properties, sometimes loading is false og hasNextPage is false/undefined, but the dataset is not fully loaded yet.

     

     

    I will try to use loadExactPage instead, and then i will try to upload the code as a solution, instead of using fiddler for testing. I suspect it could be something releated to that.

     

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: PCF Model Driven App - Not all records are loaded (Dataset)

    Hi @Kristoffer88 , 

    I'm not sure about all details (since I've used loadExactPage instead ot loadNext Page) but maybe this brings you a step forward:

    "paging.totalResultCount" is documented here https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/paging#totalresultcount 

    but I wouldn't expect it to be set in the init method. I suggest to set the page size allways on 5000 (this should work also if there are less records)

    dataSet.paging.setPageSize(5000); 

     If I see right, if  

    loading===true && dataSet.sortedRecordIds.length === dataSet.paging.totalResultCount

     there is no return, so you might land to loadNextPage() call, while still loading. 

    About unceressary loads, I've seen similar behavior in my tests; but I work with react and let it treat the unnecessary calls.

    Hope this helps. If not, please let me know.

    Kind regards,

    Diana

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 55 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 42 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 31 Super User 2025 Season 1

Overall leaderboard