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
Isabell MaticIsabell Matic 

Is there any way to see Apex classes which are not defined as global?

Best Answer chosen by Isabell Matic
Khan AnasKhan Anas (Salesforce Developers) 
Hi Isabell,

Greetings to you!

You can query from ApexClass. You can find out all you need to know about the ApexClass object in the SOAP API Developer Guide.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_apexclass.htm
SELECT id, Name, Body FROM ApexClass

But you can't use a filter on Body. Body is a Long Text Area and filtering on Long Text Area fields is not supported. 

So, you can use contains() String method. Try like this:
List<ApexClass> apexWithBody = new List<ApexClass>();
for(ApexClass ac : [SELECT id, Name, Body FROM ApexClass]) {
    if(!ac.Body.contains('global class'))
    apexWithBody.add(ac);
    System.debug('apexWithBody -> ' + apexWithBody);
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas