i need to trigger email when data storage is hitting the limit.i dont see any configuration where i can set the email based on some usage.Please suggest.Is there any way without using the third party(appexchange)tools.


I don't think you can use trigger here. But you can use scheduler class and Limit API to get these details.

Essentially, you have to build an apex class which does a callout to the REST API. You can then schedule that class to run in scheduled Apex. The big problem is that you have to pass a username and password as part of the login call to get a session:

  1. How to login and get a session -
  2. Class to call the login:
public class CurrentStorage {

public static void getStorage() {

String sid = Login.login('', '');

HttpRequest req = new HttpRequest();

req.setHeader('Authorization', 'OAuth '+ sid);

Http http = new Http();

HTTPResponse res = http.send(req);

Map m = (Map)JSON.deserializeUntyped(res.getBody());
Map dataStorage = (Map)m.get('DataStorageMB');

System.debug('Current Storage: ' + dataStorage.get('Remaining'));



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.