6

I am trying to convert our existing Salesforce (which until now has been a mess of developing straight from Sandbox to Production through changesets without much control) to Salesforce DX. I have read that Salesforce recommends spinning the existing structure into different 'artifacts', each with separate VCS, with shared custom stuff being in its own artifact that should be deployed before any of the ones depending on it.

So far so good, I have created a number of different sfdx projects, one 'base' and the others that are each dependent on things from it.

However, for the dependencies, I obviously need to have the base artifact pushed to scratch orgs before pushing the dependency itself. How can I do that? Is there a way to ask SFDX to pre-populate scratch orgs with another artifact? Otherwise, how would I ever be able to test out the dependency?

3

Refer my answer posted here

Basically, once you have your package broken into artifacts like:

force-app/shared
force-app/chatBot
force-app/recruitment

You need to version these DCP's using packaging 2 commands and then define the inter-dependency of these packages in your sfdx-project.json file something like this:

sfdx-project.json:

{   "packageDirectories": [{
      "path": "force-app/shared/default",
      "default": true,
      "id": "0Ho50000000111111",
      "versionName": "v 1.0",
      "versionDescription": "ver 1.0",
      "versionNumber": "1.0.0.NEXT",
      "ancestorId": ""
    },
    {
      "path": "force-app/chatBot",
      "id": "0Ho5000000022222",
      "versionName": "v 1.0",
      "versionDescription": "ver 1.0",
      "versionNumber": "1.0.0.NEXT",
      "ancestorId": "",
      "dependencies": [{
          "packageId": "0Ho50000000111111",
          "versionNumber": "1.0.0.LATEST"
        }
      ],
      "features": "MultiCurrency",
      "orgPreferences": {
        "enabled": [
          "S1DesktopEnabled",
          "Translation"
        ],
        "disabled": []
      }
    },
    {
      "path": "force-app/recruitment",
      "id": "0Ho5000000033333",
      "versionName": "v 1.0",
      "versionDescription": "ver 1.0",
      "versionNumber": "1.0.0.NEXT",
      "ancestorId": "",
      "dependencies": [
        {
          "packageId": "0Ho50000000111111",
          "versionNumber": "1.0.0.LATEST"
        }
      ]
    }   
   ],   
   "namespace": "",   
   "sfdcLoginUrl": "https://login.salesforce.com",   
   "sourceApiVersion": "41.0" 
}

So here you can see package chatBot and recruitment depend on shared package for some metadata components.

So once you decide to make a new org and if you push chatBot to it first, then you'll get an error saying that a dependency is missing. So you'd first need to install shared package and then install chatBot.

It's weird that even after writing the dependencies you have to manually deploy the dependency first, but Salesforce has said that they're working on making it seamless in future with more concentration on DCP's and how to break the org into packages but for now, this is the way to go.

|improve this answer|||||

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.