1

I need one help to deploy different components like classes, triggers, objects, profiles, permission sets, etc from sandbox to the production org.

I used following command to deploy all the items on the production. But I noticed that it only validates the changes and is not giving any option to deploy the components

sfdx force:source:deploy -m ApexClass:TestUtility -l RunLocalTests -c -w 3 -u myProdUserName

I read different blogs and found that we can use the command "sfdx force:mdapi:deploy" for the deployment. But, I didn't get the exact syntax/procedure or any option in the VS Code which allow deploying all the components on the production.

6

You should read through the documentation on force:source:deploy again

The reason why you're only validating the changes is because that's exactly what you're telling sfdx to do when you use the -c flag

-c | --checkonly
Optional

Validates the deployed metadata and runs all Apex tests, but prevents the deployment from being saved to the org.

Further, when using the -m flag, you're either deploying everything in your project of a particular metadata type (when you use, for example -m ApexClass), or only deploying specific components (when you use -m ApexClass:MyClass, only MyClass is deployed)

Put into words, that command you're currently running says...

deploy the testUtility class (-m ApexClass:testUtility) to myOrgName (-u myOrgName), but only verify the changes (-c). Run all local tests (-l RunLocalTests), and stop listening for updates if the operation takes more than 3 minutes (-w 3)

Using the -p flag to specify a path to deploy to is probably the easiest way to do what you're describing. Using it and pointing to the "force-app" folder would deploy everything in your project unless you've done some serious modification to your project structure.

| improve this answer | |
  • Thank You! I am using the following command to deploy only custom labels and keeping custom labels in package.xml only. sfdx force:source:deploy --checkonly -x ./manifest/package.xml -u myProdUserName --testlevel RunLocalTests It validates successfully but doesn't do the deployment and shows an error message - "INVALID_ID_FIELD: Source validate did not run tests in the org" when we run the following command. sfdx force:source:deploy --targetusername myProdUserName --validateddeployrequestid JobId – Ghanshyam Kumar Mar 30 at 15:08
  • Remove --checkonly parameter to do a deployment instead of a validation. – Abhishek Saxena Mar 30 at 19:40
4

If you use -c , note that the command will just validate it.

I suggest you use the Visualstudio For Salesforce extension and deploy using the deploy to source option as shown below

enter image description here

If you are using CLI then you have to add all the metadata and be specific in format as shown below and it will be tedious exercise instead just deploy by clicking on the path.

sfdx force:source:deploy -m ApexClass, Profile:myprofile, ApexTrigger -l RunLocalTests -w 10 -u myProdUserName

Note do not put -c there as it will only validate.

| improve this answer | |
  • Thank You! We can't use the source option as it doesn't work for the Prod deployment. I am using the following command to deploy only custom labels and keeping custom labels in package.xml only. sfdx force:source:deploy --checkonly -x ./manifest/package.xml -u myProdUserName --testlevel RunLocalTests It validates successfully but doesn't do the deployment and shows an error message - "INVALID_ID_FIELD: Source validate did not run tests in the org" when we run the following command. sfdx force:source:deploy --targetusername myProdUserName --validateddeployrequestid JobId – – Ghanshyam Kumar Mar 30 at 15:06

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.