“Enable record locking and unlocking in Apex” for scratch org

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3














Any idea how to "Enable record locking and unlocking in Apex" for scratch org?



I am getting the following error while running unit tests in scratch org:



System.NoAccessException: Apex approval lock/unlock api preference not enabled.



Appreciate your insight on this or if you know any workaround.










share|improve this question





















  • as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
    – kurunve
    Dec 18 at 16:51










  • We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
    – Tanmay
    Dec 18 at 16:54















3














Any idea how to "Enable record locking and unlocking in Apex" for scratch org?



I am getting the following error while running unit tests in scratch org:



System.NoAccessException: Apex approval lock/unlock api preference not enabled.



Appreciate your insight on this or if you know any workaround.










share|improve this question





















  • as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
    – kurunve
    Dec 18 at 16:51










  • We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
    – Tanmay
    Dec 18 at 16:54













3












3








3







Any idea how to "Enable record locking and unlocking in Apex" for scratch org?



I am getting the following error while running unit tests in scratch org:



System.NoAccessException: Apex approval lock/unlock api preference not enabled.



Appreciate your insight on this or if you know any workaround.










share|improve this question













Any idea how to "Enable record locking and unlocking in Apex" for scratch org?



I am getting the following error while running unit tests in scratch org:



System.NoAccessException: Apex approval lock/unlock api preference not enabled.



Appreciate your insight on this or if you know any workaround.







salesforcedx






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 18 at 16:40









Tanmay

8016




8016











  • as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
    – kurunve
    Dec 18 at 16:51










  • We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
    – Tanmay
    Dec 18 at 16:54
















  • as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
    – kurunve
    Dec 18 at 16:51










  • We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
    – Tanmay
    Dec 18 at 16:54















as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
– kurunve
Dec 18 at 16:51




as a workaround, you can manually enable that -- salesforce.stackexchange.com/questions/108524/…
– kurunve
Dec 18 at 16:51












We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
– Tanmay
Dec 18 at 16:54




We've already considered it but that's not an ideal alternative, as we would like to spin up scratch orgs for CI/CD purposes. Appreciate your input though.
– Tanmay
Dec 18 at 16:54










1 Answer
1






active

oldest

votes


















5














As of Winter '19, you can specify the setting ApexApprovalLockUnlock from the Metadata API's OrgPreferenceSettings entity as part of your scratch org configuration file. (Deploying settings entities with the Metadata API continues to work).



Under the "settings" key, you nest your settings entities and translate their names into camelCase:




In Winter ’19 and later, scratch org settings are the format for defining org preferences in the scratch org definition. Because you can use all Metadata API settings, they are the most comprehensive way to configure a scratch org. If a setting is supported in Metadata API, it’s supported in scratch orgs.



[...]



Although the Settings are upper camel case in the Metadata API Developer Guide, be sure to indicate them as lower camel case in the scratch org definition.



When converting existing org prefs to settings, the org prefs that start with “Is” have a corresponding setting that starts with “enable”. For example, “IsOrdersEnabled” is “enableOrders” that takes a Boolean value of true or false.




Here, you can do this in your scratch org config file:




"orgName": "Acme",
"edition": "Enterprise",
"settings":
"orgPreferenceSettings":
"apexApprovalLockUnlock": true





Then your scratch orgs will spin up with the setting already enabled:



enter image description here






share|improve this answer




















    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%2f244035%2fenable-record-locking-and-unlocking-in-apex-for-scratch-org%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









    5














    As of Winter '19, you can specify the setting ApexApprovalLockUnlock from the Metadata API's OrgPreferenceSettings entity as part of your scratch org configuration file. (Deploying settings entities with the Metadata API continues to work).



    Under the "settings" key, you nest your settings entities and translate their names into camelCase:




    In Winter ’19 and later, scratch org settings are the format for defining org preferences in the scratch org definition. Because you can use all Metadata API settings, they are the most comprehensive way to configure a scratch org. If a setting is supported in Metadata API, it’s supported in scratch orgs.



    [...]



    Although the Settings are upper camel case in the Metadata API Developer Guide, be sure to indicate them as lower camel case in the scratch org definition.



    When converting existing org prefs to settings, the org prefs that start with “Is” have a corresponding setting that starts with “enable”. For example, “IsOrdersEnabled” is “enableOrders” that takes a Boolean value of true or false.




    Here, you can do this in your scratch org config file:




    "orgName": "Acme",
    "edition": "Enterprise",
    "settings":
    "orgPreferenceSettings":
    "apexApprovalLockUnlock": true





    Then your scratch orgs will spin up with the setting already enabled:



    enter image description here






    share|improve this answer

























      5














      As of Winter '19, you can specify the setting ApexApprovalLockUnlock from the Metadata API's OrgPreferenceSettings entity as part of your scratch org configuration file. (Deploying settings entities with the Metadata API continues to work).



      Under the "settings" key, you nest your settings entities and translate their names into camelCase:




      In Winter ’19 and later, scratch org settings are the format for defining org preferences in the scratch org definition. Because you can use all Metadata API settings, they are the most comprehensive way to configure a scratch org. If a setting is supported in Metadata API, it’s supported in scratch orgs.



      [...]



      Although the Settings are upper camel case in the Metadata API Developer Guide, be sure to indicate them as lower camel case in the scratch org definition.



      When converting existing org prefs to settings, the org prefs that start with “Is” have a corresponding setting that starts with “enable”. For example, “IsOrdersEnabled” is “enableOrders” that takes a Boolean value of true or false.




      Here, you can do this in your scratch org config file:




      "orgName": "Acme",
      "edition": "Enterprise",
      "settings":
      "orgPreferenceSettings":
      "apexApprovalLockUnlock": true





      Then your scratch orgs will spin up with the setting already enabled:



      enter image description here






      share|improve this answer























        5












        5








        5






        As of Winter '19, you can specify the setting ApexApprovalLockUnlock from the Metadata API's OrgPreferenceSettings entity as part of your scratch org configuration file. (Deploying settings entities with the Metadata API continues to work).



        Under the "settings" key, you nest your settings entities and translate their names into camelCase:




        In Winter ’19 and later, scratch org settings are the format for defining org preferences in the scratch org definition. Because you can use all Metadata API settings, they are the most comprehensive way to configure a scratch org. If a setting is supported in Metadata API, it’s supported in scratch orgs.



        [...]



        Although the Settings are upper camel case in the Metadata API Developer Guide, be sure to indicate them as lower camel case in the scratch org definition.



        When converting existing org prefs to settings, the org prefs that start with “Is” have a corresponding setting that starts with “enable”. For example, “IsOrdersEnabled” is “enableOrders” that takes a Boolean value of true or false.




        Here, you can do this in your scratch org config file:




        "orgName": "Acme",
        "edition": "Enterprise",
        "settings":
        "orgPreferenceSettings":
        "apexApprovalLockUnlock": true





        Then your scratch orgs will spin up with the setting already enabled:



        enter image description here






        share|improve this answer












        As of Winter '19, you can specify the setting ApexApprovalLockUnlock from the Metadata API's OrgPreferenceSettings entity as part of your scratch org configuration file. (Deploying settings entities with the Metadata API continues to work).



        Under the "settings" key, you nest your settings entities and translate their names into camelCase:




        In Winter ’19 and later, scratch org settings are the format for defining org preferences in the scratch org definition. Because you can use all Metadata API settings, they are the most comprehensive way to configure a scratch org. If a setting is supported in Metadata API, it’s supported in scratch orgs.



        [...]



        Although the Settings are upper camel case in the Metadata API Developer Guide, be sure to indicate them as lower camel case in the scratch org definition.



        When converting existing org prefs to settings, the org prefs that start with “Is” have a corresponding setting that starts with “enable”. For example, “IsOrdersEnabled” is “enableOrders” that takes a Boolean value of true or false.




        Here, you can do this in your scratch org config file:




        "orgName": "Acme",
        "edition": "Enterprise",
        "settings":
        "orgPreferenceSettings":
        "apexApprovalLockUnlock": true





        Then your scratch orgs will spin up with the setting already enabled:



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 18 at 18:19









        David Reed

        30.2k61746




        30.2k61746



























            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%2f244035%2fenable-record-locking-and-unlocking-in-apex-for-scratch-org%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?