The Welkin Suite Forum

How do we create Scratch orgs with a specific namespace?



How do we create Scratch orgs with a specific namespace?

  • Please log in to reply

#1
windows version welkinsuite

vchaddha

    Posted 07 Jul 2019 and edited 08 Jul 2019

    I'm trying to create a Scratch with namespace, but the new scratch org is being created without the provided namespace.


    My Dev Hub has already linked the Namespace correctly and sfdx-package.json looks alright to me as well. and looks like this:


    {
      "packageDirectories": [
        {
          "path": "force-app",
          "default": true
        }
      ],
      "namespace": "myAppNamespace",
      "sfdcLoginUrl": "https://login.salesforce.com",
      "sourceApiVersion": "45.0",
      "edition": "Developer",
      "hasSampleData": false,
      "features": [
        "API",
        "AuthorApex",
        "DebugApex",
        "DefaultWorkflowUser",
        "ForceComPlatform"
      ],
      "orgPreferences": {
        "enabled": [
          "ChatterEnabled",
          "EnhancedEmailEnabled",
          "PathAssistantsEnabled",
          "S1DesktopEnabled",
          "ShowViewHierarchyLink",
          "IsActivityRemindersEnabled",
          "IsDragAndDropSchedulingEnabled",
          "IsEmailTrackingEnabled",
          "IsGroupTasksEnabled",
          "IsMultidayEventsEnabled",
          "IsRecurringEventsEnabled",
          "IsRecurringTasksEnabled",
          "ShowEventDetailsMultiUserCalendar",
          "ShowHomePageHoverLinksForEvents",
          "ShowMyTasksHoverLinks",
          "DocumentContentSearchEnabled",
          "RecentlyViewedUsersForBlankLookupEnabled",
          "SingleSearchResultShortcutEnabled"
        ]
      }
    }
    


    8 replies to this topic

    #2

    vlgubanovich

      Posted 08 Jul 2019

      Hi vchaddha,

      Thank you for your question.


      To create a scratch org with a namespace please modify the "config\project-scratch-def.json" and add the "namespace" parameter there. You can specify all additional parameters in that file. Afterward, when creating a scratch organization - select the option called "Use from project" for "Select the way to retrieve the configuration file".


      Please let me know if it works well for you.


      Thank you,

      Vladimir


      Vladimir Gubanovich
      Head of Product
       
      The Welkin Suite
      skype id: vladimir.gubanovich
      e-mail: vladimir.gubanovich@welkinsuite.com


      #3

      vchaddha

        Posted 08 Jul 2019

        Thanks Vladimir. I assumed sfdx-project.json was the source here, my bad, didn't realized there is separate config.



        #4

        vchaddha

          Posted 08 Jul 2019

          Another thing is, I can't create scratch org for 30 days using TWS, it always auto reduce it to 29 day length.



          #5

          vlgubanovich

            Posted 08 Jul 2019

            Hi vchaddha,

            I'll look at this situation in a bit more details, as the whole internet says that you should specify namespace in the project configuration, and not in the scratch org configuration (while admitting that a scratch org definition file might be a better place). So it's not 100% clear for me at the moment what is the correct way, how really it should work, and why TWS works in a different way :) Thank you for pointing this out!


            Regarding the scratch org duration - you're absolutely right, and due to some strange reason we have it limited to 29 days. I've added this fix to the current sprint, so it will be released in about 2 weeks.


            Thank you,

            Vladimir


            Vladimir Gubanovich
            Head of Product
             
            The Welkin Suite
            skype id: vladimir.gubanovich
            e-mail: vladimir.gubanovich@welkinsuite.com


            #6

            vchaddha

              Posted 08 Jul 2019 and edited 08 Jul 2019

              Also, it's very painful to "manually" edit scratch org definition. the scratch org definition is not in line with how DX documentation says it to be and there is definitely lack of TWS compliant JSON config details in the TWS online documentation.


              I tried modifying the json manually for an hour now, nad every time it failed because it turns, the JSON format is completely different than DX supplied format. Pardon my ignorance, but is there a reason to go different approach for the config? LINK


              I couldn't figure out how to pass "CustomApps" or "CustomTabs" values in scratch org, I get an error all the time.

              I am unable to create a Scratch org after I added "namespace": "myAppNamespace" to "config/project-scratch-def.json" file. my config stands like this and I am receiving error all the time.


              UPDATE: Even though error is reported by TWS, the scratch org was still created.


              {
                "orgName": "My-Scratch-Org",
                "adminEmail": "myemail@mydomain.com",
                "edition": "Developer",
                "namespace": "myAppNamespace",
                "orgPreferences": {
                  "enabled": [
                    "AsyncSaveEnabled",
                    "ChatterEnabled",
                    "EnhancedEmailEnabled",
                    "PathAssistantsEnabled",
                    "S1DesktopEnabled",
                    "SendThroughGmailPref",
                    "ShowViewHierarchyLink",
                    "IsActivityRemindersEnabled",
                    "IsDragAndDropSchedulingEnabled",
                    "IsEmailTrackingEnabled",
                    "IsGroupTasksEnabled",
                    "IsMultidayEventsEnabled",
                    "IsRecurringEventsEnabled",
                    "IsRecurringTasksEnabled",
                    "IsSidebarCalendarShortcutEnabled",
                    "IsSimpleTaskCreateUIEnabled",
                    "ShowEventDetailsMultiUserCalendar",
                    "ShowHomePageHoverLinksForEvents",
                    "ShowMyTasksHoverLinks",
                    "ShowRequestedMeetingsOnHomePage",
                    "IsChatterProfileEnabled",
                    "DocumentContentSearchEnabled",
                    "RecentlyViewedUsersForBlankLookupEnabled",
                    "SidebarAutoCompleteEnabled",
                    "SidebarDropDownListEnabled",
                    "SidebarLimitToItemsIownCheckboxEnabled",
                    "SingleSearchResultShortcutEnabled"
                  ]
                },
                "features": "API;AuthorApex;ForceComPlatform"
              }


              #7

              vlgubanovich

                Posted 08 Jul 2019

                Hi vchaddha,


                The JSON format that is currently used for scratch org definition files in the IDE is Salesforce's "org preferences". Since Winter'19 both "org preferences" and "scratch org settings" are supported, while starting from Winter'20 only "scratch org settings" will be supported.

                We will work on updating our UI scratch org configuration tool to work with the "scratch org settings" format in the nearest time, as well as we will update default templates, etc.

                Thank you,

                Vladimir


                Vladimir Gubanovich
                Head of Product
                 
                The Welkin Suite
                skype id: vladimir.gubanovich
                e-mail: vladimir.gubanovich@welkinsuite.com


                #8

                vchaddha

                  Posted 08 Jul 2019 and edited 08 Jul 2019

                  There is difference in how "Features" nodes work in TWS. SFDX Documentation specifies it as an Array, while TWS configuration generated from UI tool in TWS generated it as a ";" semi-colon separated string value. And it does not accept the format of specifying CustomApps and CustomTabs. or may be I'm missing something entirely. 


                  1. Could you guide me how to make those settings in Config JSON?

                  2. Could you also take a look at the JSON config file attached in my above post, and verify if this si correctly formatted. For some reason, it is resulting into ane rror all the time. An error that looks something like this "Unable to push settings into scratch org"



                  #9

                  vlgubanovich

                    Posted 08 Jul 2019

                    Hi vchaddha,

                    I've just played with both configurations you've provided and, unfortunately, I was not able to create a scratch org with such configuration in both The Welkin Suite and SalesforceDX CLI. For the last configuration, I've had to remove all search-related settings, and still got an internal error from SFDX CLI.

                    At the same time, for the initial configuration you've posted, I was able to create a scratch org, but I had to remove all search-related settings. Here's the config I got:

                    {
                      "orgName": "Demo Company",
                      "adminEmail": "myemail@mydomain.com",
                      "namespace": "mynamespace",
                      "edition": "Developer",
                      "features": [
                        "API",
                        "AuthorApex",
                        "DebugApex",
                        "DefaultWorkflowUser",
                        "ForceComPlatform"
                       ],
                       "orgPreferences": {
                        "enabled": [
                          "ChatterEnabled",
                          "EnhancedEmailEnabled",
                          "PathAssistantsEnabled",
                          "S1DesktopEnabled",
                          "ShowViewHierarchyLink",
                          "IsActivityRemindersEnabled",
                          "IsDragAndDropSchedulingEnabled",
                          "IsEmailTrackingEnabled",
                          "IsGroupTasksEnabled",
                          "IsMultidayEventsEnabled",
                          "IsRecurringEventsEnabled",
                          "IsRecurringTasksEnabled",
                          "ShowEventDetailsMultiUserCalendar",
                          "ShowHomePageHoverLinksForEvents",
                          "ShowMyTasksHoverLinks"
                        ]
                      }
                    }
                    

                    I also wanted to highlight, that The Welkin Suite does not use any custom-made solutions or approaches for SFDX, instead, we use SFDX CLI under-the-hood. This means that whatever functionality is supported by SFDX - it's supported by TWS as well. This applies to definition files formats, so if you'd like to use old org preferences, or if you'd like to switch to the newer scratch org settings - you can do this freely.

                    The only difference here is the UI for scratch organization configuration in the IDE that uses outdated format (correct in general, but incorrect in the "features" list as you've highlighted).
                    So just to summarize:

                    • In the case when you are building a new org definition file it might make sense to try it out with the SFDX CLI first, as it shows all issues. Once you're done testing a config and ready to use it, feel free to use it in the IDE - it will work exactly the same, as with CLI;
                    • If you already have existing working definition files - feel free to reuse them in the IDE, and they will work;
                    • I've noted the following points for us to improve: scratch org lifespan limit to 30 days; scratch org configuration tool and file format that it generates; not showing detailed errors when failing to create a scratch org due to configuration issues.

                    Hope this answers your questions.


                    Thank you,

                    Vladimir



                    Vladimir Gubanovich
                    Head of Product
                     
                    The Welkin Suite
                    skype id: vladimir.gubanovich
                    e-mail: vladimir.gubanovich@welkinsuite.com





                    Boost Your Productivity. Get Started Today

                    Try Free Trial