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

Query Salesforce Org's Storage Limit and Usage
Hello All,
Is it possible to query the storage limit of each org? Is it possible to also query how much of it is being used? I've looked in all the obvious places ($organization) and the docs. All I can find is this information displayed in the UI under company profile, but I would like to access this information programatically.
Thanks!
yad
As far as I'm aware, that isn't part of the API.
Saw this: http://stackoverflow.com/questions/11142003/how-to-retrieve-salesforce-file-attachment-limit-via-api
Perhaps there's another undocument call that someone else can shine a light on.
You could try to consume the SOAP WSDL in Apex, though this brings its own problems.
The way I've handled this in the past is to access the Company Information page programmatically (by creating a pagereference to it) and scrape the information out of the content. This is fragile though, as if the page format changes my code won't be able to find the value. Hasn't happened in 3 years though ;)
Thanks kirk, though that is a nice find it's not exactly what i was looking for. That would tell me the file size limit per file, whereas I'm looking for the total storage usage/limits for the org itself. I appreciate your help!
Thanks bob, that is definitely a clever and fun workaround, but unfortunately would not suffice for a client/product solution..
I may dig around deeper in the SOAP doc for good measure, but it looks to me like just running code off of the errors generated by surpassing these limits is, for now at least, the only way to deal with this..
for anyone interested, this is the dmlexception error text:
"Insert failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"
+1 for bob's solution. I do this too. You can use php simple dom parser: http://simplehtmldom.sourceforge.net/ to parse the page in a way that 's far less fragile. It searches for the elements like jquery.
Hi Esteve Graells,
The controller which you have written is working as expected, can you please attach the test class if you have already written.
Thanks.