0

I found the command

sfdx force:package:installed:list -u

here in this post Query for Package Ids installed on an org?

It's a line from SFDCfox's answer. I'm interested in the results that he got because I needed the IDs for the installed packages. However, can I have those command in my apex class?

0
3

No it's not possible. You cannot invoke anything that's not http request from APEX so you cannot DIRECTLY play with SFDX CLI.

As mentioned you can use HTTP though.

That means you can create some middleware server, host it somewhere (make sure that it will have access to the environment from where CLI commands will be run -> it can be the same server for example) and using HTTP calls from Apex send a request to this server ordering it to run the command.

2
  • Well, as long as you build your own proxy server, which will be externally available, then it will be possible to call any kind of a CLI command – kurunve Sep 3 '18 at 7:47
  • Well that's of course true. :) Thats why I mentioned http. I would update my answer in a moment to explain this more thorough – user1974566 Sep 3 '18 at 7:48
0

You can detect the list of installed packages from Apex using a SOQL Query ( but for strange reasons there is no field for package Id )

SELECT DurableId,IsSalesforce,MajorVersion,MinorVersion,Name,NamespacePrefix FROM Publisher WHERE MajorVersion > 0 AND MinorVersion > 0

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.