Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to know if I am about to hit the org governor salesforce limit class?

Asked by Claudine Tippins May 9, 2023 945 views 1 answer
Share

About this question

I want to avoid hitting the org's governor limits but at the same time I need to know if I was about to hit them. Here's what I have so far:

[ SELECT convertCurrency(Price__c) FROM Object__c LIMIT :(Limits.getLimitQueryRows() - Limits.getQueryRows()) ];

So this will save me from hitting the limits but it will not tell me that I was going to hit them.

Basically the case I am talking about is when the query LIMIT is 50k and the records are 50k. If Limits.getQueryRows() is 50k it doesn't necessarily mean that a limit would have been hit. But if the records are 50001 I want to know this so I can display an error on the page for the user.

I was thinking about using Count() somehow but not sure how I can achieve what I want. I am also trying to incorporate the solution without making an additional query.

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.