---
sourceDocument: Yokohama ServiceNow AI Platform Administration
sourceDocumentLink: https://www.servicenow.com/docs/r/yokohama/platform-administration

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Enforcing unique numbering

# Enforcing unique numbering {#ariaid-title1}

* Release version: Yokohama
* 
* Updated January 30, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Although duplicate numbers are rare, numbering does not enforce uniqueness, by
default.  
To enforce uniqueness, you can:

* Create a before business rule on insert only to check for duplicate values and replace duplicates with the next available number.
* Enable a unique index on the table. For more information, see [Create a table index](https://www.servicenow.com/docs/3rOQsaufDnKaG0MEIjjm7A "Build indexes to access the data held in your tables more easily.").  
  Note:  
  While unique indexes ensure data integrity they also prevent any insert involving a duplicate number. This may cause unexpected errors during data entry.
{#c_EnforcingUniqueNumbering__ul_jmq_twc_gt}

## Sample business rule

This sample script can be used as part of a before business rule on insert only to check for
duplicate numbers and replace them with the next available number. The following script
references a script created in [Configure left padding of a system number in a table](https://www.servicenow.com/docs/wi2VPPHVrvaHhYffxl_zcw "You can configure the left padding of the system numbers on a table. For example, pad the Number field on an Incident, Problem, or Change Request.").

    var curNum = current.number + '';
     
    if(curNum) {
     
      var recordClass = current.getRecordClassName();
      var now_GR = new GlideRecord(recordClass);
      now_GR.addQuery('number', curNum);
      now_GR.setLimit(1);  
      now_GR.query();
     
      if(now_GR.getRowCount() > 0) {
        var newNum = getNextObjNumberPadded();
        gs.addInfoMessage("The number " + current.number + " was already used by another " +
         recordClass + ". The " + recordClass + " number has been changed to " + newNum);
        current.number = newNum;
      }
    }

**Related topics**   

* [Business rules](https://www.servicenow.com/docs/access?context=c_BusinessRules&version=yokohama&pubname=yokohama-api-reference&ft:locale=en-US)

