Query: Select id from apexclass where class name like '%test%'.

Above query if fetching both managed and unmanaged package classes, can i filter only unmanaged package.


You can filter by the namespace prefix. Assuming your org is not a developer org:

SELECT Id FROM ApexClass WHERE NamespacePrefix = NULL AND Name LIKE '%Test%'

Alternatively, I prefer to use SOSL, so I don't accidentally pick up files that have Test in the name but are not actual tests:

FIND '@isTest' IN ALL FIELDS RETURNING ApexClass(Id WHERE NamespacePrefix = NULL)

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.