Add a unique constraint to a field

You can apply a unique constraint to individual fields in sublayers in a hosted feature layer. When you apply a unique constraint, ArcGIS Online ensures that there are no duplicate values stored in the field. You might 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.

The layer owner and the organization administrator can set unique constraints on fields in hosted feature layers and hosted tables. Members of a shared update group to which the layer is shared can also set a unique constraint on a field in the layer.

Follow these steps to add a unique constraint to a field in a sublayer of a hosted feature layer or hosted table:

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

    Details for the field appear.

  6. Click the Require unique values toggle button to enable it and click Save.

    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.

If you later decide to remove the unique constraint, click the Require unique values toggle button to disable it and click Save.