3

Enterprise Territory Management Issue

I am currently examining implementing Enterprise Territory Management. I have a Territory structure set up in the Planning stage. According to the implementation guide I can preview assigned rules to territories as stated in the document:

Run account assignment rules for any territory that has rules defined and belongs to a territory model in Planning or Active state. If your territory is in Planning state, running rules lets you preview account assignments. If your territory is in Active state when you run rules, accounts are assigned to territories according to your rules.

I currently have a rule set up to assign an account to a territory based on some BillingState values. But there is no preview. The account then gets assigned to the territory and shows up on the Assigned Territories related list on the Account record. It shows up as being in Model State value of Planning. This to me isn't a preview, I don't want this visible to end users while building it (granted I am on a dev org so it really doesn't matter at this point, but it will when I implement in production).

Related List on Account Detail page

enter image description here

It saves this relationship in a ObjectTerritory2Association object. I can not figure out how to delete this declaratively. And if I try and do it in some anonymous apex I get the following error:

System.DmlException: Delete failed. First exception on row 0 with id 0JB37000000L0DUGA0; first error: INVALID_OPERATION, An object territory association cannot be created or deleted with Territory Assignment Rule association cause.: []

My question here is how am I supposed to test all of these rules that I am creating if I can't even delete the associations to run the rules again? On top of that, why doesn't it show a preview like the documentation says?

0

When creating the Territory Account Associations, you are required to provide the AssociationCause = 'Territory2Manual'. Therefore, when you are deleting the same, you must restrict your deletion list to the same criteria [i.e. Select Id, ObjectId, Territory2Id, AssociationCause From objectterritory2association Where AssociationCause = 'Territory2Manual' And Territory2Id In :Territorys]

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.