+ Start a Discussion
Iago SilvaIago Silva 

Create scratch org with appexchange apps

Hello everybody!!

Is there a way to create a scratch org with all packages from appexchange that there are in the production?

Maybe using the project-scratch-def.json file?

Thanks in advance
Best Answer chosen by Iago Silva
SwethaSwetha (Salesforce Developers) 
HI Iago,

This should be possible based on latest  sfdcfox's comment on (https://salesforce.stackexchange.com/questions/198080/installing-managed-packages-to-scratch-org-via-configuration).

If you do not have any dependencies, the most simple format is to use a package.xml mdapi style deployment.
sfdx force:mdapi:deploy -d packages/ -u alias -w 99
Where packages/ contains a package.xml:
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>InstalledPackage</name> </types> </Package>
And, for each package to install, a NAMESPACE.installedPackage:
<?xml version="1.0" encoding="UTF-8"?> <InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <activateRSS>false</activateRSS> <versionNumber>216.10.1</versionNumber> <password>ClearTextPassword</password> </InstalledPackage>

<password> is required if the package install has a password, and must not be supplied if there is no package install password.

Check  https://salesforce.stackexchange.com/a/344386/80089 for detailed information

Also see https://developer.salesforce.com/forums/?id=9062I000000IUjPQAW

You might also want to try the Org Shape(Beta) feature.
https://developer.salesforce.com/docs/atlas.en-us.228.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_shape_create_shape.htm

If this information helps, please mark the answer as best. Thank you
 

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi Iago Silva,
Greetings!

To implement this, first, you have to enable the dev hub in the org.
Then authenticate that dev hub in Visual Studio Code using Salesforce CLI.
After this, create a scratch org.
then you can manage apps.
for refer-> https://salesforce.stackexchange.com/questions/191068/installing-an-appexchange-app-into-a-scratch-org

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi
Iago SilvaIago Silva
But this way I have to install manually every app.
I wish I had a way to automate this on creation of the scratch org
SwethaSwetha (Salesforce Developers) 
HI Iago,

This should be possible based on latest  sfdcfox's comment on (https://salesforce.stackexchange.com/questions/198080/installing-managed-packages-to-scratch-org-via-configuration).

If you do not have any dependencies, the most simple format is to use a package.xml mdapi style deployment.
sfdx force:mdapi:deploy -d packages/ -u alias -w 99
Where packages/ contains a package.xml:
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>InstalledPackage</name> </types> </Package>
And, for each package to install, a NAMESPACE.installedPackage:
<?xml version="1.0" encoding="UTF-8"?> <InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <activateRSS>false</activateRSS> <versionNumber>216.10.1</versionNumber> <password>ClearTextPassword</password> </InstalledPackage>

<password> is required if the package install has a password, and must not be supplied if there is no package install password.

Check  https://salesforce.stackexchange.com/a/344386/80089 for detailed information

Also see https://developer.salesforce.com/forums/?id=9062I000000IUjPQAW

You might also want to try the Org Shape(Beta) feature.
https://developer.salesforce.com/docs/atlas.en-us.228.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_shape_create_shape.htm

If this information helps, please mark the answer as best. Thank you
 
This was selected as the best answer
Iago SilvaIago Silva
Hi Swetha,

I ended up creating a python script to do this task. Even so , thank you for your response