I am trying to create an attribute rule that validates if a street name is in a master street table when being created. Here is the code I have so far, I am not sure where my syntax is wrong.
The expression needs to be case in-sensitive, the source data in the master table is mixed casing.
Thanks in advance!
// 1. Access the reference table by name
// This must match the name of the layer in your database/service
var masterStreetName = Upper(FeatureSetByName($datastore, 'vwAddresserData_v2', ["FULLADDRESS"], false));
// 2. Get the address being entered/edited
var addresserStreetName = Upper($feature.FullStreetName);
// 3. Handle empty values (optional: allow or block nulls)
if (IsEmpty(addresserStreetName)) { return true; }
// 4. Filter the other table for matching addresses
// Use Upper() to ensure the comparison isn't case-sensitive
var filterSQL = "FULLADDRESS = '" + addresserStreetName + "'";
var matches = Filter(masterStreetName, '@filterSQL');
// 5. Logic: Return true if a match is found, false (with message) if not
if (Count(matches) > 0) {
return true;
} else {
return {
"errorMessage": "The address " + addresserStreetName + " does not exist in the master Street table."
};
}