1

I would like to get the record count from each object (there are fair chances of getting more than 50K records) using a desktop utility and would like to create one CSV file for each object's record count till date.

1
  • I deleted my answer because, after reading the link you sent, I may well be mistaken about API limits. I am surprised though as I thought they'd be bound by the same stuff!
    – Dan Jones
    Dec 21, 2016 at 9:08

1 Answer 1

0

You can use the @ReadOnly annotation: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_ReadOnly.htm

Find below the test that I have done:

This code is without @ReadOnly annotation:

@RestResource(urlMapping='/AccountCount/*') 
global class  AccountCount_WS {
   @HttpGet
   static webservice Integer getCountAccount(){   
       Integer count = [select count() from Account];
       //just to reach more than 50k because in my sandbox I have arround 17k
       count += [select count() from Account];
       count += [select count() from Account];
       count += [select count() from Account];
       return count;

   }
}

and here I get an error when I call the WS:

[{
   "errorCode": "APEX_ERROR",
   "message": "System.LimitException: Too many query rows: 50001\n\nClass.AccountCount_WS.getCountAccount: line 9, column 1"
}]

Then I added an @ReadOnly annotation like below

@RestResource(urlMapping='/AccountCount/*') 
global class  AccountCount_WS {
   @HttpGet
   @ReadOnly
   static webservice Integer getCountAccount(){   
       Integer count = [select count() from Account];
       //just to reach more than 50k because in my sandbox I have arround 17k
       count += [select count() from Account];
       count += [select count() from Account];
       count += [select count() from Account];
       return count;

   }
}

The WebService is now able to return a value:

68992

hope it clarifies

1
  • Hi @Akram, thank you for the response. I wouldn't want writing custom Apex API for this instead looking for online documentation for maximum rows supported by standard REST or SOAP APIs. Unfortunately didn't find in the API documentation but I think I have got what I was looking for in this post. - salesforce.stackexchange.com/questions/118949/…
    – LakhanP
    Dec 21, 2016 at 11:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .