2

We would like to use the SFDX Cli to version our custom objects in a Git repository. For now, because we're new to SFDX and our codebase will be small, we want a single sfdx app.

We currently have some other packages from the marketplace that also create custom objects and add types to existing objects (They extend Account for example)

How should we import this to our SFDX app ? Should we import the default objects (Like Account) that we added fields to, but manually go through them and remove the fields added by the marketplace packages we added?

2 Answers 2

2

If you want to make use of metadata components (including custom fields, for example) added by third party AppExchange packages, the only way to achieve this is to install those packages because they will have a namespace in which all their metadata exists. You cannot reproduce these in your own source base.

Dependencies on third-party packages are captured in the sfdx-project.json. Unfortunately, scratch org creation does not automatically ensure dependencies get installed (a significant oversight in SFDX IMHO) so you will have to write your own scripting to deal with this. Once done, using SFDX for your development works quite nicely, though (depending on the size of the packages on which you depend) scratch org creation can be pretty slow.

Personally I would say you should always view your version control system as the source of truth, never an org. I would also say that, due to undesirable behaviour in sfdx around pulling metadata from a scratch org (it will see some profiles as changed by Salesforce and insist on pulling spurious updates to these - at least, that is what I have found), you should consider explicitly retrieving rather than using pull if you have to create or modify metadata on the org rather than locally in your IDE.

1
  • The best part about Unlocked Packages, though, is you can create several and install only those that you need to do development, which can reduce the scratch org creation processing time.
    – sfdcfox
    Aug 24, 2020 at 0:38
2

The best practice is to version everything that you have configured in your org that includes code, config and any customization you have done on top of packages you have installed.

The idea of the versioning should be in case you lose your org metadata for some reason you should be able to replicate by deploying metadata from the source control.

The easiest way you can accomplish this by creating an unmanaged package in your sandbox or Prod.

You can do this by following steps

  • Navigate to Set up | Packaging | Package Manager | Create a New Package

  • Add components you need to version. Note that it will auto pull all dependent metadata. This will anyways exclude metadata that is generated by other packages. But it will still include extra components you added to customize the app

  • Use the SFDX CLI command to retrieve the metadata using below command

    sfdx force:source:retrieve -n "<packagename>"
    

where Package Name(packagename) is the name of your package.

You must log in to answer this question.

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