Print this page

Does number of Javascript Remoting calls count against SOQL governor limit?

Knowledge Article Number 000187436
Description Does each java script remoting call count against SOQL Governor limit or it is considered as a new request? 

No, Javascript remoting calls don't count against SOQL Governor limit.

If you are making any call using java script remoting and invoked remoting method is a part of loop. It would be taken as a separate request in a different contexts.

For Example: if we invoke a java script on button click and that java script method is calling a remote method of Apex more than 200 times and that remote method contains a SOQL query then it would not hit Governor Limit of salesforce as all requested are taken as a different request with different context. It applied for SOQL records retrieval limit as well.

Below is the sample code for the same:

Note: You can test number of calls generated using debug logs. Advantage of using below mentioned code is that it can bypass SOQL governor limit.

Remoting Class:

// Remoting class will perform action
global with sharing class RemotingTest {

    public String accountName { get; set; }
    public static List<Account> account { get; set; }
    public static List<Campaign> camp { get; set; }
    public RemotingTest() { } // empty constructor
    global static List<Account> getAccount(String accountName) {
        account = [SELECT Id, Name, Phone, Type, NumberOfEmployees 
                   FROM Account WHERE Name = :accountName];
        return account;

Visual force Page:

<apex:page controller="RemotingTestCampaign">
    <apex:form >
    <script type="text/javascript">
    function getRemoteCampaign() {
        var r=confirm("Press a button");
        if (r==true)
          x="You pressed OK!";
          x="You pressed Cancel!";
        var cc=0;
        for(var i=0;i<101;i++){
            alert('Times of Execution');
            function(result, event){ //The result variable represents the object returned from the ApexgetAccount method.
            {escape: true}
     <input type="button" onclick="getRemoteCampaign()" value="Get Campaign" />

Note: Please make sure to test this code for all use cases.

promote demote