No Callout limit and doing dmls before callout :)

In salesforce there are strict limitations on how callouts are used. Because they take much resources. One of the most important limitations which needs to be considered while doing integrations with external systems is doing DML before the callout. Salesforce does not permit doing DMLs before the callout. This post is about using PageReference.getContent()  and doing as many callout as you want and also doing DML’s before callout.

Here is the code:

Create the page as follows:

Create the class as follows:

Thats it..Now you are ready.


When you run this code in anonymous block, you can see in limit section callout counter still shows ZERO. Try doing more than 10 callouts, you will see that counter is ZERO which means you can make more than 10 callouts. 🙂

So you will get the response from this method. I tried making 24 callouts in a single transaction, which took nearly 20 seconds and code proves you can make DML’s before callout.

By this method you can make Http GET or POST callout. So this approach gives you the place where you will see some limits will not act. Like

1. DML’s will not get counted.

2. SOQL’s will not get counted.

Note: Add the urls in remote site settings. Limits in salesforce are there with good reasons. Use this only when you have no option.

[If you are not able to see code then follow this]

Feel free to leave your comments.


5 thoughts on “No Callout limit and doing dmls before callout :)

  1. Curt DeBlaey March 6, 2014 at 7:28 pm Reply

    What is the DataHolder class in the CallOutUtil? Is that a SalesForce class, or one that you created? Thanks.

    • kmachhewar March 7, 2014 at 5:25 am Reply

      Actually was experimenting to pass data through static member variable of DataHolder class. I should have commented/removed that line. I will change it. That is not required. Thanks for notifying. Let me know if you face any issues using this.

      • Curt DeBlaey March 7, 2014 at 3:41 pm

        Thank you for the prompt reply! And thank you for the code example, too.

  2. kushnit April 24, 2014 at 5:30 am Reply

    Is this a salesforce bug? If it is then Salesforce may fix it in future and all our implementation fail.

    • smachhewar April 24, 2014 at 8:56 am Reply

      I think its a loophole in the system. Yes salesforce has every right to fix this in future. But we all do so many workaround to bypass limits and every workaround has its sideffects. If salesforce fixes this then certainly implementation based on this will fail. Need to use this approach with much care.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: