I am trying to sieve out duplicate values within the column "ID" from the table "IDs" and am getting different results for using the same arcade expression with Calculate Field tool and Validation Rule. The expression gives the intended output for the Calculate Field tool but Validation Rule outputs Error 002717, at line 3, where it seems to suggest that it is unable to read the ${id} variable. I have also tried the method of adding the string with the variable id to no avail.
var tbl = FeaturesetbyName($datastore, "IDs", ["ID"], false);
var id = $feature.ID
var query = `ID = ${id}`;
var countID = Count(Filter(tbl, query));
function isDup(value){
if (value > 1){
return false;
} else {
return true;
}
}
isDup(countID)
Solved! Go to Solution.
Do you have empty id values? In that case, your query would be "ID = ", which is an invalid query.
var id = $feature.ID
if(id == null) { return false } // feature is invalid if no id
var tbl = FeaturesetbyName($datastore, "IDs", ["ID"], false);
var query = "ID = @ID"; // try using this notation instead
var countID = Count(Filter(tbl, query));
return countID == 1 // valid if exactly 1 feature has this ID, else invalid
Do you have empty id values? In that case, your query would be "ID = ", which is an invalid query.
var id = $feature.ID
if(id == null) { return false } // feature is invalid if no id
var tbl = FeaturesetbyName($datastore, "IDs", ["ID"], false);
var query = "ID = @ID"; // try using this notation instead
var countID = Count(Filter(tbl, query));
return countID == 1 // valid if exactly 1 feature has this ID, else invalid
There weren't any empty records. But the query fix you suggested worked for line 3 of the original code.
Thank you so much, @JohannesLindner !