I have a VF,which shows org wide limits,

<apex:page controller="SFLimitController" contentType="text/html" docType="html-5.0">
<apex:pageBlock title="Hello {!$User.FirstName}!" helpTitle="LIMITS"  HElpUrl="https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_limits.htm">
<b>Salesforce Limits</b>
<apex:form >
<apex:pageBlock id="pg1">
<apex:panelGrid columns="4">
<apex:pageBlockSection id="pgs1">
<apex:pageBlockSectionItem >

and the controller is:

public with sharing class SFLimitController{
public String Response { get; set;}

public SFLimitController()

public String fetchData(String GET)
Http h=new Http();
HttpRequest req=new HttpRequest();
req.setEndpoint('https://cs24.salesforce.com/services/data/v36.0/limits/ ');
 req.setHeader('Authorization','OAuth '+UserInfo.getSessionID());

HttpResponse res=h.send(req);
             return res.getBody();


As of Now,I am getting vf display in single line or as paragraph..how do i get the vf display in tabular format.Do guide me in the formatting process of vf.

  • if you make a callout to /services/data/v36.0/limits endpoint you will get list of records with there limit. You can just simply show those records in VF page
    – Ratan Paul
    May 25 '16 at 8:50
  • 1
    Why use the REST API? If you're building a VisualForce page, you're already inside Salesforce and have an Apex controller. You can just use the Limits Apex class to find that information.
    – mkorman
    May 25 '16 at 9:16
  • yeah good point by mkorman. You can use limit class as well
    – Ratan Paul
    May 25 '16 at 9:20

Let me be elaborate about the limits in salesforce. There are two types of limit in Salesforce. 1.Transactional Limit : These limits exists over a particular transaction(when you press a butoon etc), like 100SOQL,150DML,100Callouts in transaction, 10 seconds transaction timeout. These limits gets reset every time a new transaction starts.

2.Org wide limits: These are orgwide limits and does get reset with often day change/or data change. eg 10000API limit /24hours, 100GB data storage etc.

In order to get tranactional limit you can directly use LIMIT class. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_limits.htm

for Org wide limits ,you can make a callout using the below code.

 Http http = new Http();
 HttpRequest request = new HttpRequest();
 request.setHeader('Authorization','OAuth '+UserInfo.getSessionID());

 HttpResponse response = http.send(request);

Output will be:


As you can see,whole org wide limit is displayed in JSOn, now you need to parse that JSON and display it on your VF page.

  • 1
    Thank you for the detailed explanation.. It was helpfull.
    – priya
    Jun 1 '16 at 11:21
  • If my answer helped, you can upvote and mark it as solve, it will help others to reach solutions faster. Jun 2 '16 at 6:02

I would suggest using a different approach: use the Limits Apex class. I don't see why you need the REST API for this if you're creating a VF page. The REST API is designed to allow external systems to communicate with your Salesforce, but a VF is inside salesforce. You're making your life more complicated if you want to use that API.

Broadly speaking, you would have to do this:

  • Create an Apex controller for your VF page. The controller should have properties representing all the limits you want to show.
  • Have your controller use the Limits class above to populate those properties
  • Create a VF page that shows the controller's properties using something like an outputText

That should give you all the building blocks you need to create such a page.

  • Thanks all for the reply, can you provide me a small example of how to go with it..
    – priya
    May 26 '16 at 6:27
  • Why don't you edit your initial question, put your code there, and see how we can all help you? You just wrote the controller (you can give it a different name, as it does nothing with Rest). The values should be stored as properties (developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…) and then, for the Visualforce, here is a question similar to what you ask, with plenty of information: salesforce.stackexchange.com/questions/31752/…
    – mkorman
    May 27 '16 at 7:47

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.