Play Games

Search This Blog

Wednesday, December 4, 2024

How to get Salesforce Org limits in Apex


Solution:
Use the below code

List<System.OrgLimit> lstOrgLimits = OrgLimits.getAll();

for (System.OrgLimit objLimit : lstOrgLimits) {

    System.debug('Limit        : ' + objLimit.getName());

    System.debug('Current Limit: ' + objLimit.getValue());

    System.debug('Max Limit    : ' + objLimit.getLimit());

}

Output:

To get specific limit, for example file storage limit use the below code

System.OrgLimit objLimit = OrgLimits.getMap().get('FileStorageMB');

System.debug('Limit        : ' + objLimit.getName());

System.debug('Current Limit: ' + objLimit.getValue());

System.debug('Max Limit    : ' + objLimit.getLimit());

Output:



No comments:

Post a Comment