.. _prevent-duplicate-numbers:

Prevent duplicate numbers
-----------------------------

.. _25.2|VOSS-1445:


.. tip:: 

   :ref:`use-action-search-to-navigate-automate`



Overview 
..........

Automate provides a Global Setting for Microsoft deployments, *Prevent Duplicate Numbers*, 
which prevents the system from creating duplicate numbers in the internal number inventories of different sites, 
either manually via number range management or automatically via syncs. 

When *Prevent Duplicate Numbers* is enabled, any attempt to provision a number that already exists at another site 
will fail, stopping duplication at the source and surfacing a clear error for administrators to resolve. This includes 
a scenario where you're provisioning a number via, for example, flow through provisioning set up for 
*Use Next Available Line*. In this case, if duplicates exist and the number is available at one of these sites, 
the transaction will fail as the number is already in use at one site. The user is synced in, moved, and provisioned, 
but no number is assigned. 

This feature allows administrators to ensure that the internal number inventory contains unique directory numbers 
across sites. When relevant workflows are triggered, the system checks for existing numbers before creating new 
ones, partially failing transactions that would result in duplicates (only the duplicate number creation step fails), 
and logs errors for review.

Preventing duplicate numbers is relevant only for the internal number inventory. E164 numbers, for example, are 
unique and cannot be re-used. However, if you're using E164 dial plans, it is recommended that you enable 
prevention of duplicate numbers as you may not realize that duplicates are being created and added to your 
internal number inventory during syncs and when creating number ranges. 

For deployments that allow duplicate numbers, you can leave *Prevent Duplicate Numbers* disabled (*No*). 

The table describes scenarios that may result in the creation of duplicate numbers, and how enabling 
*Prevent Duplicate Numbers* handles these cases:

.. note:: 

   When HCS dial plans are in use, *Prevent Duplicate Numbers* is a read-only setting and is disabled for 
   syncs or when creating number ranges. 

.. tabularcolumns:: |p{5cm}|p{10cm}|

+-----------------------------------------------------------+-------------------------------------------------------------+
| Scenario                                                  | *Prevent Duplicate Numbers* enabled                         |
+===========================================================+=============================================================+
| Sync in a user to a site (SiteA) with their number, but   | The number is not created at SiteA. The rest of the sync    |
| number already exists at another site (SiteB)             | workflow executes successfully. A transaction error informs |
|                                                           | you that the number already exists at SiteB.                |
|                                                           |                                                             |
+-----------------------------------------------------------+-------------------------------------------------------------+
| Create a number range at customer level, and part of the  | The duplicate number is not created, but the                |
| range already exists at the customer or at any site below | rest of the (valid) number range is created. The            |
| it                                                        | log message flags numbers in the range that are duplicates, |
|                                                           | and indicates their current location (site or customer).    |
+-----------------------------------------------------------+-------------------------------------------------------------+
| Create a number range at the site level, and part of the  | The duplicate number is not created, but the rest of the    |
| range already exists at the customer, the current site,   | (valid) number range is created. The log message flags      |
| or at other sites in the customer tree                    | numbers in the range that are duplicates and indicates      |
|                                                           | their current location (site or customer).                  |
+-----------------------------------------------------------+-------------------------------------------------------------+
| Run a data sync workflow at the customer level that       | A number that already exists at the customer level is       |
| triggers the creation of an internal number inventory     | updated and marked as *Used*.                               |
| (INI) at the customer level                               |                                                             |
|                                                           | A number that exists at a single site belonging to the      |
|                                                           | customer is updated with additional details from the sync.  |
|                                                           |                                                             |
|                                                           | For a number that exists at multiple sites, the transaction |
|                                                           | fails with async errors with a message indicating           |
|                                                           | that the number won't be created due to existing duplicates.|
|                                                           |                                                             |
|                                                           | If a number does not exist at the customer or at any sites  |
|                                                           | belonging to the customer, the transaction passes, and the  |
|                                                           | number is created and marked as *Used*.                     | 
+-----------------------------------------------------------+-------------------------------------------------------------+
| Run a data sync workflow at the site level that triggers  | A number that already exists at the customer is updated and |
| the creation of an internal number inventory (INI) at the | marked at *Used*.                                           |
| site level                                                |                                                             |
|                                                           | If any number exists at any other sites, the transaction    |
|                                                           | completes with async errors with a message indicating the   | 
|                                                           | that the number won't be created due to existing duplicates.|
|                                                           | The number at the other site is updated with the new user   |
|                                                           | details.                                                    |
|                                                           |                                                             |
|                                                           | If a number exists at the target site it is updated with    |
|                                                           | details and marked as *Used*.                               |
|                                                           |                                                             |
|                                                           | If a number does not exist at the customer or any site, the |
|                                                           | transaction succeeds, the number is created and marked as   |
|                                                           | *Used*.                                                     |
+-----------------------------------------------------------+-------------------------------------------------------------+


.. rubric:: Related topics
 
* 
  .. raw:: latex

     Global Settings in the Core Feature Guide

  .. raw:: html
  
     <a href="concepts-global-settings.html">Global Settings</a> 

* :ref:`view-a-transaction`
* :ref:`transaction-logging-and-audit`
* 
  .. raw:: latex

     Introduction to data syncs in the Core Feature Guide

  .. raw:: html
  
     <a href="concepts-data-sync.html">Introduction to data syncs</a> 



Configure prevention of duplicate numbers 
...........................................

1. In the Admin Portal, select the relevant customer hierarchy. 

   .. note:: 

      The **Prevent Duplicate Numbers** global settings is hidden in the global settings at the site or 
      linked site level. The setting displays only above site or linked site level and only when 
      Microsoft is enabled for your environment. 

2. Go to **Global Settings**. 
3. On the **Number Inventory** tab/panel, set **Prevent Duplicate Numbers** to *No*. 

   ..  note:: 

       In the Global Settings, this field is enabled and can be configured only when 
       **Enforce HCS Dialplan Rules** is set to *No* (disabled).

4. Save your changes. 


Troubleshooting duplicate numbers 
...................................

Assuming you have *Prevent Duplicate Numbers* enabled, if you're creating a number range or syncing 
in users and your transaction results in a number inventory error where the number could not be created 
because it already exists, then try the following steps to resolve the error, depending on your scenario:

* Delete the number range range from the site where the duplicate exists, then recreate the number range at the 
  new site. You can then run an audit of the number inventory. 
* The user you're syncing in may have been assigned an incorrect number (a number that already 
  exists at another site in Automate) in the Microsoft Teams cloud portal, or they've been synced in to the 
  incorrect site. In this case: 
  
  * Either move the user to the site where their number exists
  * Or, offboard the synced in user and assign a different number 

.. rubric:: Related topics 

* :ref:`offboarding-ms`
* :ref:`run-dni-audit-tool`
* :ref:`move-ms-subscriber`
* :ref:`move-user-without-services`
* :ref:`number-range-management`