I'm in the process of pushing my production org's metadata into a scratch org. For the most part, the migration is very simple but the biggest gotcha is getting around appexchange dependencies. Any flexipage or report could easily be reference fields or components from an existing app exchange app and cause a number of deployment issues to the scratch org.

SFDX has a nice feature that allows you to install packages from the with sfdx force:package:install -i 04t... -u myScratchOrg

However, tracking down the package Id is very tedious. My current technique is to go to the appExchange, search for the app (which is now a newer version), click the install link and copy the Id from the URL.

Additionally, I could end up installing a dependency that does not match up to my production instance or find that the latest version of the package isn't backward compatible.

Is there an easier way to find these older package Ids? Such as the tooling API or SOQL query?

1 Answer 1


Just run the following command:

sfdx force:package:installed:list -u <alias|username>

This will give you all of the packages installed, including the 04t "AllPackageVersion" Id that you need to install an app.

Sample output:

=== Installed Package Versions [4]
ID                  PACKAGE ID          PACKAGE NAME                           NAMESPACE    PACKAGE VERSION ID  VERSION NAME  VERSION
──────────────────  ──────────────────  ─────────────────────────────────────  ───────────  ──────────────────  ────────────  ────────
0A341000000PiVGCA0  03330000000wDAbAAM  Salesforce Connected Apps              sf_com_apps  04t30000001DUvrAAG  Winter '16
0A3410000007m6CCAQ  03341000000GPjnAAG  Opportunity Management Workflow Rules               04t41000002FoDoAAK  January 2017
0A341000000eZqxCAE  03341000000TWaHAAW  Trailhead Playground                   th_con_app   04t41000001MvrkAAC  1.10
0A341000000nRDtCAM  033B00000000XvZIAU  DreamHouse                                          04tB00000009UeXIAU  Summer 2017

Note that this command, for some reason, requires a project directory, so if you need one, use sfdx force:project:create -n <name> beforehand.

  • WOW! how did I miss this? Commented Jan 29, 2018 at 21:02
  • @MatthewMitchener It wasn't in earlier versions. I suspect they added it in Winter 18 or Spring 18.
    – sfdcfox
    Commented Jan 29, 2018 at 21:10
  • @sfdcfox can we run that command in an apex class then retrieve the details of the installed packages in my org?
    – cookie
    Commented Sep 12, 2018 at 9:10
  • 2
    @cookie No, this is a DX command. The basic equivalent in Apex Code would be to call the Tooling API with a query like select id, name, namespaceprefix from metadatapackage.
    – sfdcfox
    Commented Sep 12, 2018 at 13:00
  • @cookie You could run this in the Developer Console's Query Editor, as long as you check the Use Tooling API checkbox. Thanks @sfdcfox! You are amazing 🙏 Commented Nov 25, 2021 at 21:27

You must log in to answer this question.

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