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
MyGodItsColdMyGodItsCold 

Governor violation - How to Predict - How to Avoid

Our users can target in on data sets with over 10,000 Contacts.

I have a VF page to gather criteria. Once I have the criteria, I'd want to say,

"Narrow your selection criteria, you're about to get too many Contacts."

How do I do that? I thought I'd run a SOQL 'intNumberOfContacts = SELECT count() FROM Contact WHERE ....'

but when it goes over 10,000, it bombs.

I thought I'd use try ... catch ...    But, as the documentation says, you can't catch from a blown
governor limit.

What am I to do?

Thanks.
BoxBox

I had exactly the same issue and have been bouncing it off a lot of different people and there isn't to much we can do other than put a limit on the SOQL to stop it firing the gov limit.

I ended up essentially limiting the SOQL response and if the data set returned is equal the limit imposed than i assume there are more records to process.  Its not fool proof but its my only solution so far :(