6

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?

11

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    1.7.0.1
0A3410000007m6CCAQ  03341000000GPjnAAG  Opportunity Management Workflow Rules               04t41000002FoDoAAK  January 2017  1.0.0.1
0A341000000eZqxCAE  03341000000TWaHAAW  Trailhead Playground                   th_con_app   04t41000001MvrkAAC  1.10          1.10.0.1
0A341000000nRDtCAM  033B00000000XvZIAU  DreamHouse                                          04tB00000009UeXIAU  Summer 2017   2.0.0.1

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? – Matthew Mitchener Jan 29 '18 at 21:02
  • @MatthewMitchener It wasn't in earlier versions. I suspect they added it in Winter 18 or Spring 18. – sfdcfox Jan 29 '18 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 Sep 12 '18 at 9:10
  • 1
    @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 Sep 12 '18 at 13:00

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.