Overriding the Default Territories Setting

3 minute read time.
When you insert a new record, the Territory field defaults to a territory called Default. This is not a true territory, but a territory placeholder. The Default entry remains in the field until the user selects a territory from the Territory field. The territories available to the user are as defined by the System Administrator.

If the user does not select a territory, the record is automatically assigned a territory according to the territory security management set up by the System Administrator and a set of system rules.

The detail of these rules are described in the System Administrators Guide.

But let's imagine that someone creates a new Company and leaves the setting to be Default. What happens is that CRM will try and add the company to the territory of the user that is assigned to the company. If the creator doesn't have insert rights over the assigned user's territory the new record will be added to the creator's territory.

So if we think about the demo system then the user Susan Maye (who is in the territory "US & Canada") can create a new company and assign it to Brian Little (territory: "US West") it will then get added to Brian's territory not Susan's. But if Brian was to try and create a company and assign it to Susan, because Brian does not have insert rights over the "US & Canada" territory for the company table the new record will get added to Brian's home territory "US West".

Now it can be the case that the System Administrator may want to create a special common territory for Companies. The System Administrator can set up security profiles so that if the records (e.g. Companies) are added to a particular territory then all users will have absolute rights to see records (Companies) in that territory. This is useful when all users of the system need to see all Companies but only the communications, opportunities and cases etc need to be kept private to the users home territory.

So if we want to make sure that when a new Company is created it gets added to that common territory by default what do we need to do?

1) The first thing to do is check that all users via their Security Profiles have rights to insert company records into the common territory. If they don't and the step 2 of the instructions are followed then you will start generating "An unexpected event has occurred" errors.

Note: When a record is attempted to be inserted into a territory by automatic code for which the user does not have insert rights then it can create a ""An unexpected event has occurred" error. This may not show up in the SQL logs but it will show up in the System Log. Things to watch out for are:

UserActionException,ErrMsg Security violation inserting into table Company. You do not have insert privileges in the XXXXXXXX territory.
An unexpected event has occurred : Exception: Security violation inserting into table Company. You do not have insert privileges in the XXXXXXX territory.

2) In the companyboxlong screen you can add the following code to the Create Script of the comp_secterr field to set the value to the common territory.

DefaultValue = -2113929208;
ReadOnly = true;

In the above example -2113929208 represents the demo territory "US West". You will need to get the value of the territory you are interested in from the table "territories".

Note: The default Person for a company created this way will get added by default to the same territory as the Company.
Parents Comment Children
No Data