Thursday, 31 December 2020

How to display Salesforce Data Storage Limits for the current Org ?

How to display Salesforce Data Storage Limits for the current Org ?


For the population of data storage limits in the VF, we need just a small rest API code.

HttpRequest req = new HttpRequest();
req.setEndpoint('https://.salesforce.com/services/data/v37.0/limits/');
req.setMethod('GET');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
// Create a new http object to send the request object
// A response object is generated as a result of the request
Http http = new Http();
HTTPResponse res = http.send(req);
String jsonStr = res.getBody();

Map m = (Map)JSON.deserializeUntyped(jsonStr);
System.debug('Data Storage:' + m.get('DataStorageMB'));
System.debug('HTTP response' + jsonStr);

But actually we are holding a current version 50.0 but in the code i have written with the older version.
In the above mentioned version we will get all the data storage limits and api call limits but we can't get the data info like how many records were created per object (count).

example : If you have to populate the data count of the standard objects and custom objects in the vf.
so this can't be happened through the normal soql query, means you have to write the query on multiple objects but instead of writing the multiple lines of code this can be achievable via a simple rest API callout.

In the new version 50 by changing the above code EndPoint URL to the /services/data/v50.0/limits/recordCount?sObjects=Account,Contact

we can fetch the data count..

Hope above info is helpful , Thank you :-)

Sunday, 22 November 2020

Tools for Lightning Web Component Development

 Below are the tools required for Web Component Development 1. Chrome Browser (Prefered) You can download it from Google 2. Visual Studio Co...