Dependent models SOQL doesn't update with updateData

Our story begins with 2 models:

“Members” : ordinary custom sObject model, condition where Id = Param.Id. Limit 100 records
“UtilityAccount” : custom sObject, condition where Id IN any row from "Members: model. Limit 1000

The trouble is that users weren’t getting warnings for bad data on page load if the error was on row #101 or greater. So I changed the limit on “Members” to 1000 records. Life was great in Userville, the page load was a drop slower but Users we’re so excited that they got errors on page load, that they barely noticed. 

Suddenly the Apex Heap size error reared it’s ugly head. Users were frightened and disturbed by this. Anytime there were more than 500 or so “Members” the page wouldn’t load!

Enter the loadNextOffset method! This was added to the API recently, and I immediately spun up a snippet as detailed here: https://community.skuid.com/t/options-around-managing-large-datasets-and-apex-heap-siz… . Now my “Members” model loaded incrementally and all was peaceful.

But then the darkness returned, I could easily load my “Members” incrementally, but even when members went up to 100 or so records, “UtilityAccount” was still stuck at 100. This is because on the initial creation of the “UtilityAccount” model, “Members” only had 100 records. Although that had already increased to 1000, “UtilityAccount” was none the wiser!

I tried updating the “UtilityAccount” models data,

utilityAccounts.updateData();

to no avail… the SOQL was still limited to the original 100 “Members” rows. 

So I immediately scoured the kingdom community, and found this post : https://community.skuid.com/t/how-do-i-refresh-updatedata-a-model-with-a-dependent-mod… . Just update simultaneously! It seemed great, just do a little something like this:

skuid.model.updateModel([members, utilityAccounts]); 

The problem is that my “Members” model is limited to 100 rows, so even when they are reloaded together, the limit 100 on the “Members” model doesn’t let the “UtilityAccount” model realize that there are more records. If I set the limit back to 1000, the page won’t load.

Faced with no other options, our hero sent out a desperate plea for help.

Sorry for all the randomness, I’m trying to make a lengthy question readable.





Another wandering soul saw the faint flare of desperation.  After looking off into the distance and recognizing it was a cry for help,  he realized it was too dark and too late for him to embark on the journey immediately.  So he gathered what he would need,  made a small fire,  drank some fine brew and rested up to make a good effort in the morning. 

And so a new chapter begins…

I ended up waiting until the “Members” model finishes loading all of it’s records, and then I load the “UtilityAccount” model later, when the user clicks a button.

I’m just having some issues with Users who are too impatient to wait until the “Members” model finishes loading. If they click the button (that loads "UtilityAccount"s) before the “Members” model finishes loading, they end up with a bunch missing…

I can probably hide/disable the button until the “Members” model finishes, but I’m having some trouble figuring out, in Javascript, when it’s done…

Is there any way I can tell if

model.loadNextOffsetPage();

returns nothing?

This method…

loadNextOffsetPage ( callback )

If the Model had a LIMIT clause applied to it and there are rows in the database which were not fetched in a prior query thenloadNextOffsetPage fetches the next “set” of data based on the LIMIT clause size.

PARAMETERS:

  • callback (function): Optional. A function to be called when the data has been loaded.
I’m wondering how I can tell that there are no more records to load. 


Have you looked at the myModel.canRetrieveMoreRows property? It might be what you’re looking for.