0

I have created Restful Resource (Http Get API) to fetch the data from Salesforce. I have more than 9 Lac records in my custom object which I need to send via API. I have implemented the Max Row and Offset to overcome the Governor Limits. Now the problem I am facing is I need to send the total record count with the response.

For Ex. User calls the API with maxLimit as 5000 records, API will return 5000 records but there are more records for the same criteria and hence I need to send the total count for that. I know I can do the Count() query to find the total number but if the total records are more than 50000 than it will give error "System.LimitException: Too many query rows: 50001".

Any Idea for this? Thanks

  • Why not use a normal query instead of a class? – sfdcfox Apr 24 '18 at 10:20
  • I an creating query dynamically based on the parameters passed by user – Nirav Shah Apr 24 '18 at 10:23
  • Okay. Still doesn't explain why not use the normal REST API. – sfdcfox Apr 24 '18 at 10:24
  • @sfdcfox The reason behind the class is I need to expose the data to the external website and before sending than this records I am applying some logic to the data – Nirav Shah Apr 24 '18 at 11:14
4

As per Summer 18 release notes The SOQL Count() Function Doesn’t Count (As Much) Toward Limits.

So now you can make this query and it will be counted as 1. You might need to wait few more days to get this in your sandbox or you can sign up for pre release org and can check this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.