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
r1985r1985 

Count of account records

Hi,

 

How to find the count of account records if there are more than 2 lakh records?

 

Thanks,

Malar

Sarv333Sarv333

Hi Malar,

 

we cannot get the count if org has more than 50000 records, we will get Too many query rows exception.

Idea is we need to break the calls. 

or

it is possible through the VF Page workarounds.

also I have got other work around in vf page using JavaScript Query.

try this.

put the below code in your vf page. you can see the count of records, if this workaround will work for you, pass the value to your controller. 

 

 

<apex:page  >

 <script type="text/javascript">
  var __sfdcSessionId = '{!GETSESSIONID()}';
 </script>
 
 <script src="../../soap/ajax/22.0/connection.js"
  type="text/javascript"></script>
  <script type="text/javascript"> 
  
  window.onload = setupPage;

   function setupPage() {
     var state = { 
     output : document.getElementById("output"),
     startTime : new Date().getTime()};
     var callback = {onSuccess: layoutResults,onFailure: queryFailed,source: state};
     sforce.connection.queryAll("Select Id, Name From Account ",callback);
    }
    
  function queryFailed(error, source) { 
   source.output.innerHTML = "An error has occurred: " + error;
  }
  
  function layoutResults(queryResult, source) {
    output = queryResult.size +" ";
    source.output.innerHTML = output;
  }
  </script>
<div id="output"> </div>
</apex:page>