An admin has added a formula field to our production org that includes a reference to a field from a 3rd party managed package.
I want to bring this field into our sfdx project codebase now, but will get an error when creating scratch orgs because our scratch orgs obviously don't have the 3rd party managed package installed.
Is there a way to get around this issue? I have tried adding the managed package to the list of dependencies in the sfdx-project.json
file of our sfdx project, but it doesn't seem to get installed when a scratch org is created.
Even if that is possible, I'm still not 100% sure whether we would get charged for scratch org deployments with this package installed, as it is a paid package?
Best Answer
Only paid orgs pay for paid AppExchange Apps. Packages in Developer Edition, Scratch, and Sandbox Orgs are always free. You will want to create a script for setting up your Scratch Org environment that includes installing the package, something like this:
Note that the setup you describe is likely correct for the situation where you want to create an Unlocked Package version. You need the dependency in the sfdx-project.json and the formula field in the source directory. The only thing you're missing is the install of the package, which must be done as a separate step after creating the Scratch Org.
Do take the time to read force:package:install for available options (e.g. if you need an installation key).
You can also use a separate folder and use force:mdapi:deploy and deploy multiple packages in a single API call, as describe in my other answer.