11

I'm trying to convert one of my company's apps to Salesforce DX for continued development, but pushing the source retrieved from the current Developer Edition org isn't working.

I've created a new SFDX Project, and haven't changed the scratch org definition file.

For this app, there is a Developer Edition org where we handle all development and packaging. I used the Metadata API to download the managed package, using the command:

sfdx force:mdapi:retrieve -s -u user@company.net -p "App Name" -r ./mdapipkg

This gave me a file, unpackaged.zip. I unzipped that package, and converted it using the following:

sfdx force:mdapi:convert -r ./mdapipkg

I have a scratch org ready to go, spun up from our company's Dev Hub. I'm logged into that scratch org using the browser-based flow. I tried to push the now converted source to that scratch org using:

sfdx force:source:push -u scratch-org@demo_company.net

This gives me a list of errors. Among them, all of the Apex classes have an error saying that a certain Visualforce Page doesn't exist. Many of those classes don't reference that page. The issue is, that page does exist, and is in the pages folder within my project.

Is there a step I'm missing in converting our package to a SFDX project?

  • Is the visualforce error the first error you get? Once thing about deploying source to a scratchorg via sfdx is that a lot of errors that are returned from a failed push are the result of an initial dependency failing to deploy – tagCincy Dec 19 '17 at 21:05
  • 2
    A couple other things to check are the package.xml from the expanded mdapi package and making sure you can see the "missing" source within the sfdx source directories – tagCincy Dec 19 '17 at 21:05
  • 1
    Issues like this are what stop me from using SFDX in production- I could spend a day or two pruning the source, and be behind on my deadlines, or I could just keep working instead.. – battery.cord Dec 20 '17 at 15:07
  • If it's a managed package, feels like it could be a namespace issue - are you setting the namespace when you create the scratch org? – BritishBoyinDC Dec 20 '17 at 17:58
  • Most probably you have some recursive dependencies, for example. Visualforce page uses custom object that you try to deploy, but some field in that object reference to the same Visualforce page. You need to split your metadata folder into separate artifacts (data model, classes, lightning component) and try to deploy separately, one by one. – steals Dec 21 '17 at 16:15
1

In general, you can successfully grab all the metadata from an org, but there will be difficulty deploying all that metadata to another org. Often you will encounter dependencies and other issues that stop the deployment.

Try to narrow down what you are deploying, or focus on a single package. The force:source:push command has the ability to do exactly this and limit what is being deployed. See:

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm

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.