You need to sign in to do that
Don't have an account?

Chatter Limits in Apex
I know that the limit to the number of entities that a user can follow is 500.
There is an Idea (http://success.salesforce.com/ideaView?id=08730000000HgdbAAC) to increase the limit so I don't want to hardcode 500 anywhere in case it changes.
My question is how can I programatically get that number in Apex?
The use case is code that automatically creates EntitySubscriptions, but fails when the 500 is reached. I know that I can surround the insert with a try/catch, but reaching 500 isn't really an exception case. I want to be able to detect it without having to insert and without having to hardcode a 500 or have a 500 in a custom setting.
Ideally, I'd be able to query how many the user has and check it against a number that I get through a built-in SF class or something to that effect.
I don't see anything in the Limits methods:
Thanks.
If( a < 500) {
System.debug(' ---------' + a);
}
Thanks for responding, but what I want to know is how to get the 500 programmatically without hard coding or getting through a custom setting...or if there is another way? I don't want to have to deploy code or remember to change a custom setting when SF changes the limit.
Also, have you tried running that code as a non sys admin user? SF throws a runtime error if I don't include a Limit clause that limits it to at most 1000 possible records when querying EntitySubscriptions as a non sys admin user. Error in that situation (below) is easily fixed by adding Limit 500 in the SOQL statement.
caused by: System.QueryException: Implementation restriction: EntitySubscription only allows security evaluation for non-admin users when LIMIT is specified and at most 1000