function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chyun87chyun87 

How to query more than 100 records when using <apex:remoteObjectModel>

Dear SF experts,
I am currently trying to implement Remote Objects in Javascript to retrieve Accounts but having difficulty finding a workaround to query for more than the maximum limit of 100 records. Salesforce states that the maximum limit to return one batch of results is 100 but there is more than 2000 records that I need to query.  

Would I have to use offsets and batch query 100 records at a time?
Here is some sample code that I was working with:
j$(document).ready(function() {
            var acctTable = j$('[id$="accounttable"]').DataTable({
                "ajax": function(data, callback, settings) {
                    var acct = new SObjectModel.Account();
                    acct.retrieve({
                        orderby: [{
                            Name: 'ASC'
                        }],
                        limit: 1000
                    }, function(err, records) {
                        if (err) alert(err.message);
                        else {
                            callback({
                                'data': records
                            });
                        };
                    });
                },

Any advice would be appreciated!
Thanks.
PratikPratik (Salesforce Developers) 
Hi Chyun,

As per the documentation:
Use limit to specify how many records to return in one batch of results. The default value is 20. The maximum is 100.

You can refer to:
http://www.salesforce.com/docs/developer/pages/Content/pages_remote_objects_using_retrieve_query_object.htm

Thanks,
Pratik
chyun87chyun87
Hey Pratik,
Thanks for your comment. I was actually wondering how I can query for more than the maximum of 100 records... 

Thanks,
Sai Ram ASai Ram A
Just a quick thought wanted to share, though this may Help:)
 
<apex:page Controller="listCont" readOnly="true">
    <head>
        <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />
        
        <script>
            j$ = jQuery.noConflict();
            j$(document).ready( function () {
                var contactTable = j$('[id$="contacttable"]').DataTable({
                    order: [[2, 'asc']],
                    
                    initComplete: function() {
                        var api = this.api();
                        var select = j$('[id$=accountSelect]');
                        api.column(0).data().unique().sort().each( function ( d, j ) {
                            select.append( '<option value="'+d+'">'+d+'</option>' )
                        } );   
                    }
                });

                j$('[id$=accountSelect]').change(function() {
                    var val = j$.fn.dataTable.util.escapeRegex(
                        j$(this).val()
                    );
                    contactTable.column(0)
                        .search( val == 'All' ? '' : '^'+val+'$', true, false )
                        .draw();
                });
            });
            
                     
            
    </script>
    </head>
    <body>
        
        <table id="contacttable" class="display">
            <thead>
                <tr>
                    <th>Account Name</th>
                    <th>Fax</th>
                    <th>Phone</th>
                </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!accountList}" var="accounts">
                    <tr>
                        <td>{!accounts.Name}</td>
                        <td>{!accounts.Fax}</td>
                        <td>{!accounts.Phone}</td>
                        
                    </tr>
                </apex:repeat>
            </tbody>
        </table>
    </body>
</apex:page>

Controller
 
public class listCont{

public List<Account> accountList {
        get {
            if (accountList == null) {
                accountList = [SELECT Name, Fax, Phone FROM Account limit 10000];
            }
            return accountList;
        }
        set;
    }

}

Thank you
Sai

 
vigoroushakevigoroushake
Did you ever find a solution for this?