How to get namespace of all packages installed in a salesforce organization?

StackOverflow https://stackoverflow.com/questions/23176671

  •  06-07-2023
  •  | 
  •  

سؤال

I want to fetch the namespace prefix of all packages installed in a salesforce organization.How can I do that?

هل كانت مفيدة؟

المحلول

One fairly simple method would be to query and ApexClass object and get the distinct NamespacePrefix values.

Select NamespacePrefix from ApexClass Group By NamespacePrefix

This assumes that every installed managed package has at least one ApexClass, which may not be the case. You could expand it to include the ApexPage and ApexTrigger sObjects. Again, the managed package doesn't have Visualforce pages or triggers this won't pickup the namespace either.

A more comprehensive option is to use the listMetadata call against the MetaData API. This can be a bit more fiddly to invoke from Apex.

Incidentally, the salesforce.stackexchange.com site is a great place to ask Salesforce specific questions.

نصائح أخرى

SOQL = "SELECT NamespacePrefix FROM PackageLicense"

This SOQL query will retrieve all installed packages with their respective Namespace(s)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top