Add a unique constraint to a field

You can apply a unique constraint to individual fields in sublayers in a hosted feature layer or hosted table. When you apply a unique constraint, ArcGIS Online ensures that there are no duplicate values stored in the field. Do this for fields you intend to use to uniquely identify features in the layer. When editors update attributes or add features to a layer, the unique constraint ensures the editor does not add duplicate values. When you append or update data in the feature layer, if the file you use to append or update fields contains a value that violates the unique constraint, the append or update operation will fail.

In most cases, unique constraints are applied to numeric fields, but you can set a unique constraint on any field type except system fields such as ObjectID, GlobalID, and FID. To add a unique constraint to a string field, the maximum length defined for the field must be less than 4001.

Complete the following steps to add a unique constraint to a field in a sublayer of a hosted feature layer or hosted table:

  1. Sign in to the organization.

    You must be the layer or table owner, an organization administrator, or a member of a shared update group to which the layer or table is shared.

  2. Open the item page for the hosted feature layer or hosted table.
  3. Click the Data tab.
  4. If the hosted layer contains more than one sublayer, use the Layer drop-down menu to choose the sublayer to configure.
  5. Click the Fields button Fields to change to the Fields view.
  6. Click the display name of the field to which you will add a unique constraint to open the details for the field.

    You cannot add a unique constraint to a layer that participates in a joined hosted feature layer view.

  7. Click the Edit button Edit next to Unique values and change the setting.
    • To require that the field contain unique values, choose Require unique values and click Save.
    • To allow duplicate values in the field, choose Do not require unique values and click Save.

    When you require unique values, ArcGIS Online confirms that existing values in the field are unique. If they are, the unique constraint is added. If values are not unique, you cannot set a unique constraint on this field until you edit the field so it contains only unique values.