4

Is there any way to Query and see If a class in the Org is Managed or not ?

SELECT ApiVersion,Body,BodyCrc,CreatedById,CreatedDate,Id,IsValid,LastModifiedById,LastModifiedDate,LengthWithoutComments,Name,NamespacePrefix,Status,SystemModstamp FROM ApexClass

Is there any specific attribute for a class/trigger/VFPage sObjects to find if its Managed or not ?

I just want to query for Managed classes in the org and display(say in a table)

Thanks in advance.

1 Answer 1

6
SELECT Body,BodyCrc,LengthWithoutComments,Name,NamespacePrefix 
FROM ApexClass
WHERE NamespacePrefix != null

is a good start. Managed code will be hidden (examine the Body, BodyCrc and LengthWithoutComments columns). But the columns don't filter properly (they display as "-1" for example but WHERE LengthWithoutComments < 0 gives me no results.

So perhaps you'll have to filter them out from your result set manually.

VF pages' code is visible though (but VF components aren't). But SELECT Markup,Name,NamespacePrefix FROM ApexPage will give you HUGE results so maybe omit the Markup column.

2
  • Tried various possible way to filter . No luck. Is it a bug that it returns me records with values -1 even after i put this filter condition ? (WHERE LengthWithoutComments > 0) ? or is there any other way to filter it properly other than looping through results and then filtering?
    – Soberano
    Commented Jan 19, 2014 at 10:13
  • I think check by prefix is enough as it should be applicable to managed packages only: salesforce.com/us/developer/docs/apexcode/Content/… Are you getting false positives anywhere? (managed class/trigger but the Length... > 0)?
    – eyescream
    Commented Jan 19, 2014 at 11:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .