All Collections
Territories
How to set up auto-assignment of territories in Mapsly (step-by-step guide)
How to set up auto-assignment of territories in Mapsly (step-by-step guide)

Learn how to turn on auto-assignment for objects, auto-save assigned territories to the data source and use them in Mapsly

Sergey Shurygin avatar
Written by Sergey Shurygin
Updated over a week ago

This feature requires a Pro or Enterprise Mapsly plan.

Mapsly can automatically assign your records to territories created in Mapsly and - optionally - save the assigned territories to these records in the data source.

Add/remove territory groups to/from auto-assignment

For each territory group you may specify whether its territories should participate in the auto-assignment process or be excluded by (un)checking the Auto-assign records to territories in this group box in the Territory group properties popup.

Territory auto-assignment limit

Your Mapsly organization account comes with a default limit of 100 territories that may participate in auto-assignment, which can be increased for an additional fee. Contact us in chat or at [email protected] to request an increase of this limit.

If you accidentally add too many territories across all territory groups included in the auto-assignment process (those with the Auto-assign records to territories in this group box checked) and exceed this limit, the auto-assignment process will automatically suspend with a message inviting you to request an increase of the limit or remove some territory groups from the auto-assignment.

How to activate auto-assignment

To activate auto-assignment of records, you'll need to select the objects that you'd like to auto-assign to territories in the Territory management settings pop-up:

1- Activate auto-assignment for desired objects

  • Open the Territories pane by selecting Territories in the header of the right pane (or by selecting Territories in the main menu):

  • Open the Territory management popup by clicking the Cog icon in the pane's header:

  • Select the objects whose records need to be assigned to territories:

  • For each of the selected objects, you may, optionally, select the target CRM field to which Mapsly will save the assigned territories.

    Note #1: If you don't select a CRM field, the assigned territories will be saved in two Mapsly system fields that pre-exist in every object: Territories and Territory codes (the format of their values is described below). Selecting a CRM field will copy the value of the Territories field into the selected CRM field in your data source.

    IMPORTANT NOTE #2: Be extra careful: selecting a CRM field in this selector will overwrite your existing data in that field in all object records in your data source.

2- Create your territories

Create territories as described here (you can draw their shapes using the Mapsly shape editor or by selecting areas from the geo-library).

IMPORTANT! Adding a territory to a territory group with the checked Auto-assign records to territories in this group setting will include this territory in the auto-assignment process, while adding a territory into a group with that setting unchecked will exclude it from auto-assignment.

When done creating territories, don't forget to click Save territories for your changes to take effect.

3- Auto-assignment process will start automatically

Every time you make changes to your territories or your records' location changes, Mapsly automatically determines within which territories each record is located and saves the list of such territories to two system fields Territories and Territory codes, and - if a target CRM field was selected for this object - copies the value of the Territory field to that field (and its value immediately propagates to your data source).

Format of values in Territory and Territory codes fields

Assigned territories are saved into two pre-existing system fields: Territory and Territory codes, which serve different purposes.

Territory field

The Territory field contains the name of the assigned territory:

If a record is located within multiple [overlapping] territories at once, the Territory field will contain a comma-separated list of names of those territories.

The Territory field is easily readable by users and covers simple cases of territory management.

Note. Unlike territory codes, territory names are not required to be unique in your Mapsly organization.

Territory codes field and using auto-assignment with automation

The Territory codes field (Mapsly API name: mapsly_territories_codes) contains a JSON array with the codes of all territories to which a record belongs, and for each of those territories the code of its territory group:

[
{
"territoryName": "...",
"groupName": "...",
"territoryCode": "...",
"groupCode": "..."
}
]

A code here is a unique identifier of a territory or a territory group in your Mapsly organization, similar to API names of objects and fields. Codes are not visible to Mapsly users and are helpful, for example, to distinguish territories with the same name that belong to different groups.

This field helps address more complex scenarios in which simply saving names of the assigned territories is not the desired result, and is especially useful when used with the Mapsly automation suite.

Example. If you have two distinct groups of territories - "Sales territories" for sales reps and "Logistics territories" for logistics - and you'd like to save a comma-separated list of the assigned sales territory codes to CRM field Sales territories, while the list of logistics territory codes to a CRM field Logistics territories, you can create a workflow with the following condition/action block:

  • Condition:
    record.mapsly_territories_codes != oldRecord.mapsly_territories_codes

  • Actions:

      • Field: Sales territories
        Target value:
        {% if record.mapsly_territories_codes is not null %}

        record.mapsly_territories_codes | filter(i => i.groupCode == ‘Sales territories’) | map(i => i.territoryCode) | join(‘, ’)

        {% endif %}

Implementation services, including configuration of workflows, are included in your Mapsly subscription free-of-charge. So if you need any custom business logic implemented in Mapsly, contact us in chat or at [email protected] - and our engineer will configure them within hours.

Did this answer your question?