Getting Heap Size error, but 'Max # of records (Limit)' is not working for me.

  • 1
  • Question
  • Updated 2 months ago
  • In Progress
Hi, I have two skuid pages and when I load a good number of data (for ex, even 17,000 records) on my pages, then it shows the heap size error stating 'Apex heap size too large'. I have already tried putting the 'Max # of records (Limit)', it worked for one page but the other page is still showing the same error. Also, there is a button on the page (which started working fine after putting the limit), which changes the status of one of the fields on being clicked. But, unfortunately it is only changing the status of the records which are being displayed on the page after putting the limit and not of all the records in the database. But I need to change the status of all the records in one go (which is the actual requirement). Can you please suggest a better approach to deal with this heap size error, as setting the limit dosen't seem to be working for me and the client needs all the records to be loaded automatically in one go on page load and he won't have to press the 'Load More' option all the time. If the solution could be achieved by standard features of skuid then it is the best thing, but if there is any custom js code to achieve the solution, then please share it here and guide me how to put it in the editor and from where to call it as I am new to Skuid. I could have read the skuid documents to learn more about the skuid pages development but it will consume more time and at present I have got this issue by client who needs the solution on urgent basis. Kindly help me in getting this issue resolved, I need the solution urgently. Your help will be highly appreciated.
Photo of Vivek Pathak

Vivek Pathak

  • 100 Points 100 badge 2x thumb

Posted 2 months ago

  • 1
Photo of Mike Dwyer

Mike Dwyer, Champion

  • 4,518 Points 4k badge 2x thumb
Photo of Vivek Pathak

Vivek Pathak

  • 100 Points 100 badge 2x thumb
Thanks for the above link. Using that, I got below code which helped me in getting all the data on page load. 
(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
      var model = skuid.model.list()[2];
      model.recordsLimit = 500;
      $.blockUI({ message: 'Loading all available '+model.label+'...' });
      model.loadAllRemainingRecords({
         stepCallback: function(offsetStart,offsetEnd) {
            $.blockUI({ message: 'Loading ' + model.label + ' ' + offsetStart + ' to ' + offsetEnd + '...' });
         },
         finishCallback: function(totalRecordsRetrieved) {
            $.blockUI({ message: 'Finished loading all ' + totalRecordsRetrieved + ' ' + model.labelPlural +'!', timeout: 2000 });
         }
      });
});
})(skuid);

But, there are some filters on my page, when I apply any filter, it again starts displaying data in chunks, and I have to press 'Load More' action to display more records. Need to know, how can I make the above code work even when I apply any filters. As, there is no option to add action on these filters, then from where I can call this snippet and how can I make my functionality run as expected (i.e load all the data in one go even after applying filters). Please suggest the best. If there is any way the above code could work for my requirement, then please share how to make it happen & where to call this snippet, and the above code is for page load, so on selection of any filter if this code needs any modification then please share the modified code with me as I have not much knowledge about js. Thanks for the help in advance.
Photo of John Dahlberg

John Dahlberg, Champion

  • 3,914 Points 3k badge 2x thumb
You can use a model action and use the trigger point of "Model Requeried" to run your snippet.  Note that your script is an inline resource and you'll need to convert it to a snippet.