function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

APEX and Data Limits

We're a 3rd party developer using FDC as our platform.


We're looking for a way, preferably in APEX, to query the amount of used data space.  The usual limit for an org is 1GB - our goal is to perform specific actions when a customer begins to approach this limit.


One approach we thought of was to count the number of rows in each object, because every row takes up 2K.  But we store data in over 30 objects and I'm concerned about governors.


I looked in the docs under the Origination table and I couldn't fine any reference to org storage amount, and there is nothing in the Apex Limit class. Looks to me that this data point is not exposed to the Apex layer or the web services layer either.


But you might be able to "help" the situation.


Go through all of your data objects and pull out all the ones that you use for "setup" reasons, and use the feature Custom Settings instead. If you already do this then good job.

One issue with using Custom Settings, if you need the user to input data or change data you might want to build a visualforce page to do this. Just to make sure the data is entered in the correct way, plus the Custom Settings UI is plain.


You can also take comfort in knowing Salesforce lets it's customers go over it's data limit, so if your app pushes an org over the top for some reason the admin will receive lots of emails to do something about it. So you could create a Visualforce page that the admin could go to and selectively delete data from your app.


Thanks - yes we're already using custom settings.  A lot of them in fact- we have a set of pages that make up a "Setup Wizard" for them.


The docs say that emails get sent, but I haven't found that to be the case.  The org just stopped accepting new once it got past the 10% buffer past 1G.  Have you actually gotten one before?


The other thing we wanted to do was have it email our support team as well, so the customer could be contacted by phone.  Some of them have a habit of ignoring a lot of their email.


Thanks for the suggestions - I'll post back to this thread with our eventual solution.