How to push code to production with VS Code & DX












3














I am using VS Code to develop new functionality.



However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



INVALID_OPERATION: rollbackOnError option must be true on a production org


and



INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


The code is in the new "source format" but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




To deploy source to an org without source tracking (to an org that’s
not a scratch org), right-click a manifest, a source file, or a
directory in the Visual Studio Code explorer. Select SFDX: Deploy
Source to Org.



https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




However, the Salesforce DX Developer Guide seems to imply it:




Release Your App to Production



After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




Question 2: If I don't need to convert the source format and can push to production directly, how do I set up VS Code / CLI to avoid the two errors?










share|improve this question



























    3














    I am using VS Code to develop new functionality.



    However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



    INVALID_OPERATION: rollbackOnError option must be true on a production org


    and



    INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


    The code is in the new "source format" but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



    Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




    To deploy source to an org without source tracking (to an org that’s
    not a scratch org), right-click a manifest, a source file, or a
    directory in the Visual Studio Code explorer. Select SFDX: Deploy
    Source to Org.



    https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




    However, the Salesforce DX Developer Guide seems to imply it:




    Release Your App to Production



    After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




    Question 2: If I don't need to convert the source format and can push to production directly, how do I set up VS Code / CLI to avoid the two errors?










    share|improve this question

























      3












      3








      3


      1





      I am using VS Code to develop new functionality.



      However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



      INVALID_OPERATION: rollbackOnError option must be true on a production org


      and



      INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


      The code is in the new "source format" but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



      Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




      To deploy source to an org without source tracking (to an org that’s
      not a scratch org), right-click a manifest, a source file, or a
      directory in the Visual Studio Code explorer. Select SFDX: Deploy
      Source to Org.



      https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




      However, the Salesforce DX Developer Guide seems to imply it:




      Release Your App to Production



      After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




      Question 2: If I don't need to convert the source format and can push to production directly, how do I set up VS Code / CLI to avoid the two errors?










      share|improve this question













      I am using VS Code to develop new functionality.



      However, after completing the testing in the sandbox, I want to push the code to production. When I choose "SFDX: Deploy Code to org", it fails with errors -



      INVALID_OPERATION: rollbackOnError option must be true on a production org


      and



      INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations


      The code is in the new "source format" but I'm not developing in scratch orgs (I started the project with "SFDX: Create Project with Manifest").



      Question 1: Do I need to convert the source to Metadata API format before I can deploy to production? This is not how the instructions in release notes are written:




      To deploy source to an org without source tracking (to an org that’s
      not a scratch org), right-click a manifest, a source file, or a
      directory in the Visual Studio Code explorer. Select SFDX: Deploy
      Source to Org.



      https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_vscode_any_org.htm




      However, the Salesforce DX Developer Guide seems to imply it:




      Release Your App to Production



      After you convert from source format to metadata format, and package metadata from one org, you can release your app in a different org.



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




      Question 2: If I don't need to convert the source format and can push to production directly, how do I set up VS Code / CLI to avoid the two errors?







      deployment metadata-api salesforcedx salesforcedx-cli vs-code






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      t0tl

      185




      185






















          1 Answer
          1






          active

          oldest

          votes


















          4














          You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






          share|improve this answer





















          • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
            – t0tl
            2 hours ago






          • 2




            @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
            – sfdcfox
            2 hours ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "459"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244951%2fhow-to-push-code-to-production-with-vs-code-dx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






          share|improve this answer





















          • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
            – t0tl
            2 hours ago






          • 2




            @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
            – sfdcfox
            2 hours ago
















          4














          You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






          share|improve this answer





















          • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
            – t0tl
            2 hours ago






          • 2




            @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
            – sfdcfox
            2 hours ago














          4












          4








          4






          You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.






          share|improve this answer












          You have two choices. First, you can use force:package commands to create an unlocked package. You can install this in production with force:package:install; it is similar to installing an AppExchange package. Otherwise, you would need to use force:source:convert to get a mdapi style format, then use force:mdapi:deploy with the relevant test level (e.g. RunLocalTests) and set rollbackOnError to true. Check out the Salesforce CLI Reference for specific details, or sfdx help force:<command> for command-level help direct from the console. I do not believe that you're currently allowed to create unlocked packages directly via the GUI, but you can open a terminal by using the Terminal > Create New Terminal option, which will open a sfdx environment by default.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          sfdcfox

          247k11188424




          247k11188424












          • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
            – t0tl
            2 hours ago






          • 2




            @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
            – sfdcfox
            2 hours ago


















          • Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
            – t0tl
            2 hours ago






          • 2




            @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
            – sfdcfox
            2 hours ago
















          Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
          – t0tl
          2 hours ago




          Thank you for making the 2 options explicit. I think my disconnect was that I was expecting the entire development workflow to go through VS Code menus.
          – t0tl
          2 hours ago




          2




          2




          @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
          – sfdcfox
          2 hours ago




          @t0tl I expect it will some day, but today isn't that day. Right now, it's focused more on development, but there's a few places that are either unclear or not implemented yet.
          – sfdcfox
          2 hours ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f244951%2fhow-to-push-code-to-production-with-vs-code-dx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          サソリ

          広島県道265号伴広島線

          Accessing regular linux commands in Huawei's Dopra Linux