HOW TO

Identify duplicate field value using ArcGIS Arcade in a Map Viewer form configuration

Last Published: December 1, 2025

Summary

In Map Viewer, duplicate-value validation can be applied to ensure data integrity and prevent users from entering repeated values in key identifier fields. This article provides the workflow to detect duplicate entries using Arcade by populating 'Duplicate' in the form-calculated field.

Procedure

Note:
Ensure an empty string field is created for the Arcade expression configuration before attempting the workflow provided. Refer to ArcGIS Online: Add a field or Portal for ArcGIS: Add a field for more information.
  1. Open the web map in Map Viewer.
  2. In the Layers pane, select the layer. In this example, the feature layer 'Test' is selected.
  3. On the Settings (light) toolbar, navigate to Configure editing and click Forms.
  4. In the Configure form window, under the Form builder pane, under Fields, double-click the field containing the value to be validated. In this example, the field Asset_ID is used.
  5. Click the selected field to open the Properties pane.
  6. In the Properties pane, under Logic, ensure the Editable, Required, and Visible checkboxes are selected.
  7. Close the Properties pane.
  8. In the same Form builder pane, under Fields, double-click the field to be configured with the Arcade expression. In this example, the field Duplicate_Checker is used.
  9. Click the selected field to open the Properties pane.
  10. In the Properties pane, under Logic, for Calculation expression, click Expressions.
  11. In the Calculated expressions window, click + New expression.
  12. In the Arcade editor window, configure the expression below.
    1. Replace <feature_layer_name> with the name of the feature class containing the field to check for duplicate values. In this example, 'Test' is used.
    2. Replace <field_name> with the name of the field in the attribute table to check for duplicate values. In this example, Asset_ID is used.
var features = FeatureSetByName($datastore, '<feature_layer_name>', ['<field_name>', 'OBJECTID'], false);

for (var i in features) {
    if ((i.<field_name> == $feature.<field_name>) && (i.OBJECTID != $feature.OBJECTID)) {
        return "Duplicate";
    }
}

return "Accepted";

The code below demonstrates the full working script.

var features = FeatureSetByName($datastore, 'Test', ['Asset_ID', 'OBJECTID'], false);

for (var i in features) {
    if ((i.Asset_ID == $feature.Asset_ID) && (i.OBJECTID != $feature.OBJECTID)) {
        return "Duplicate";
    }
}

return "Accepted";
  1. Click Done.
  2. Click OK to save the form.

The map shows 'Duplicate' populated when a record with the duplicate asset ID is specified and a new feature is created.

Article ID: 000035700

Software:
  • ArcGIS Online
  • Portal for ArcGIS
  • ArcGIS Enterprise

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options