3

I am trying to create a scratch org with Territory2 enabled, as we have this in our production org and I want to mimic it as good as possible.

The full documentation for this metadata can be found here.

I have set up the scratch org definition to enable Territory2, however I am unsure what values to add to the other parameters. I am referring to:

  • defaultAccountAccessLevel
  • defaultCaseAccessLevel
  • defaultContactAccessLevel
  • defaultOpportunityAccessLevel
  • t2ForecastAccessLevel

According to the page referenced above, the field type is "string", however I cannot find any information about what string would related to which value in the settings. For example, for Account we have the following options:

Users in a territory can:

  1. View accounts assigned to
  2. the territory View and edit accounts assigned to the territory
  3. View, edit, transfer, and delete accounts assigned to the territory

What string value would relate to each of these options?

Reference scratch org json below:

{
  "orgName": "Sample Org",
  "edition": "Enterprise",
  "language": "en_US",
  "hasSampleData": true,
  "settings": {
      "territory2Settings": {
        "enableTerritoryManagement2": true,
        "defaultAccountAccessLevel": ????,
        "defaultCaseAccessLevel": ????,
        etc...
    }
  }
}
2
  • Do you really need to config all those parameters ? developer.salesforce.com/docs/metadata-coverage/51/Territory2/…
    – Badbaxx
    Jan 14, 2021 at 14:59
  • Yes, as I am trying to deploy source that requires these to be set up correctly. Either way, what I am asking for are the possible values for those parameters for the metadata api, it does not have to be specific for scratch orgs. I find it strange that the potential values are not listed in the documentation.
    – Bast
    Jan 14, 2021 at 15:34

2 Answers 2

3

Based on the comment by @sfdxfox I retried the data from an org where I manually set the different values in the GUI.

For future reference for anyone having this issue, here are the possible values (separated by a comma, in top-to-bottom order of possible alternatives in the GUI):

"territory2Settings": {
        "enableTerritoryManagement2": true,false
        "defaultAccountAccessLevel": "Read","Edit","All",
        "defaultCaseAccessLevel": "None","Read","Edit",
        "defaultContactAccessLevel": "Edit",????,
        "defaultOpportunityAccessLevel": "None","Read","Edit",
        "t2ForecastAccessLevel": "Read","Edit"
    }

Interestingly, I found no way of changing defaultContactAccessLevel in the GUI so I do not know the other possible values to this option (if there are any)

I found the full list of values: Here

1

There is a further bit of documentation, just in a different place.

However, it seems to also be incomplete. Your best option is to retrieve these settings from an existing org, then use those values in the JSON configuration file:

sfdx force:source:retrieve -m Settings:Territory2 -u production

Using the values from the mdapi output is your best option to make sure the values are correct. The two in the documentation appear to be Read and Edit, the others are not so clear, and I don't have an org set up with this to test.

1
  • Thank you, that sounds like a good way forward. I'll retrieve the values and post them here for future reference.
    – Bast
    Jan 15, 2021 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .