6

I am getting this limit exception : System.LimitException:Too many callouts: 11

when I make a callout as this exception can not be catch, can someone help me how to handle this exception on visualforce page

any help will be appreciated.. Thanks

  • Can you share some of your (controller) code - like where you are performing the callouts ? You'll most likely need to change your implementation design. – Samuel De Rycke Sep 18 '13 at 9:22
  • I made a callout after 1 second on KeyUp event so if user press keys more than 10, it throws this error. – Mahi Sep 18 '13 at 9:33
  • You could keep track of your callouts, and limit them when you're at 9 if this is all in one VF view context. Alternativly you could process every keyUp with remote Javascript which will give you a fresh set of governor limits for its execution. – Samuel De Rycke Sep 18 '13 at 9:40
  • thanks for the help.. can you provide me some code for remote javascript.. – Mahi Sep 18 '13 at 9:45
8

You cannot catch limit exceptions. Instead you need to prevent causing one. You can use the Limits class methods to find out how many callouts you have remaining.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm

Call Limits.getLimitCallouts() and check that this is greater than 0 before making a callout.

As Sdry has said, it sounds like you may need to refactor your design

  • Thanks for the help.. I try it, if it is helpful to me.. – Mahi Sep 18 '13 at 9:37

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.