Activity Forums Salesforce® Discussions How can I use 'query more' using javascript remoting?

  • Surbhi

    Member
    June 8, 2016 at 2:01 pm

    Hi Ravi,

    Please have a look on below code:

    @RemoteAction

    public static SObject[] getRecords(Id offsetId) {
    if(offsetId == null) {
    return [SELECT Id, Name FROM Contact ORDER BY Id ASC LIMIT 100];
    } else {
    return [SELECT Id, Name FROM Contact WHERE ID > :offsetId ORDER BY Id ASC LIMIT 100];
    }
    }

    function handleResult(result, event) {
    // handle a batch here
    // do more
    if(result.length===100)
    {!$RemoteAction.controller.getRecords}(result[99].Id,handleResult);
    }
    }
    {!$RemoteAction.controller.getRecords}(null,handleResult);

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos