+ Start a Discussion
Ikram Momin 16Ikram Momin 16 

Retrieve the Package name of the installed packages in an org

Hi

Is there a way to retrieve the Package name of the installed packages in an org ?

We are using below to retrieve the Package name of the installed packages in an org :
SELECT Id, NamespacePrefix FROM PackageLicense

'Package name' field is not there in PackageLicense sobject
However If checked on Salesforce.com >> Build >>Lighening Bolt >>Installed Packages >>Package Name
Here We see Package Name and want to get this Package name via soql

Is there any soql which will give us 'Package Name' ? 
SwethaSwetha (Salesforce Developers) 
HI Ikram,
As per the documentation https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_packagelicense.htm there is no field called Name that could be accessed to fetch it.

The close one you can fetch via SOQL is to query the publisher object that gives the installed package's publisher's name (not the installed package name)

select Name, MajorVersion, MinorVersion from Publisher

You might want to try Workaround of using SFDX CLI listed in : https://salesforce.stackexchange.com/questions/186025/how-to-we-get-list-of-installed-packages-and-it-version-number


Related: https://salesforce.stackexchange.com/questions/232180/retrieve-the-package-name-instead-of-publisher-name
https://salesforce.stackexchange.com/questions/226788/retrieve-package-name-package-version-of-the-installed-packages-in-org

Please consider submitting this as an idea on IdeaExcahnge so that the salesforce product development team can consider implementing it based on the number of upvotes.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
SwethaSwetha (Salesforce Developers) 
UPDATE:
You can run the below query via the tooling rest API .This should list all the packages installed in the org with their versions .
SELECT Id, SubscriberPackageId, SubscriberPackage.NamespacePrefix,
  SubscriberPackage.Name, SubscriberPackageVersion.Id,
  SubscriberPackageVersion.Name, SubscriberPackageVersion.MajorVersion,
  SubscriberPackageVersion.MinorVersion,
  SubscriberPackageVersion.PatchVersion,
  SubscriberPackageVersion.BuildNumber
 FROM InstalledSubscriberPackage
 ORDER BY SubscriberPackageId

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you