Attribute Assistant add-in in ArcMap used to have a "Validation Attribute Lookup" functionality were you could type in the first couple of characters and it would do a quick search against a table in the background and list a set of filtered choices top on a drop down to pick from. Something like an Autocomplete Dropdown control you would come across on the web.
I was not able to find an equivalent feature while setting up Attribute Rules in ArcGIS Pro. Is there something similar to the "Validation Attribute Lookup" available or did ESRI just take that feature away?
Solved! Go to Solution.
The address solution has a constraint rule, you could adapt it to find the closets match to the input and fill out value:
// This rule will ensure the full name exist in the Master Road Name table
// It will compare the left and right municipality to the municipality in the Master Road Name table
// If the left and right municipality are different there will need to be a road name for each municipality in the Master Road Name table
// Define the Road Centerline fields
var fullname_field = "fullname";
var munileft_field = "munileft";
var muniright_field = "muniright";
// Define the Master Road Names fields
var masterfullname_field = "fullname";
var mastermuni_field = "municipality";
// If the fullname is blank or null return
If (!HasKey($feature, fullname_field)) return true;
var fullname = $feature[fullname_field];
If (IsEmpty(fullname)) return true;
// Get the left and right side municipalities
var munileft = $feature[munileft_field];
var muniright = $feature[muniright_field];
var municipalities = [munileft, muniright];
// This function will attempt to find partial matches in the master road name table
function findPartialMatches(search_municipalities) {
//Attempt to find partial matches and return in error message
var partialMatches = [];
var fullname_parts = Split(fullname, ' ', -1, true)
var muni_clause = mastermuni_field + " IN @search_municipalities"
if (Includes(search_municipalities, null)) {
muni_clause = "(" + mastermuni_field + " IS NULL OR " + mastermuni_field + " IN @search_municipalities)"
}
for (var i in fullname_parts) {
if (Count(fullname_parts[i]) < 3) continue;
var search_string = "%" + fullname_parts[i] + "%";
var masterRoadNames = Filter(FeatureSetByName($datastore, "MasterRoadName", [masterfullname_field, mastermuni_field], false), muni_clause + " AND " + masterfullname_field + " LIKE @search_string");
for (var road in masterRoadNames) {
var roadname = `${road[masterfullname_field]} (${road[mastermuni_field]})`
if (!Includes(partialMatches, roadname)) {
Push(partialMatches, roadname );
}
}
}
return partialMatches;
}
// Search the master road name table for a row matching the fullname and municipality
var muni_clause = mastermuni_field + " IN @municipalities"
if (Includes(municipalities, null)) {
muni_clause = "(" + mastermuni_field + " IS NULL OR " + mastermuni_field + " IN @municipalities)"
}
var masterRoadNames = Filter(FeatureSetByName($datastore, "MasterRoadName", [masterfullname_field, mastermuni_field], false), muni_clause + " AND " + masterfullname_field + " = @fullname");
// If the left and right side municipality we only need one matching record
// If no matching records are found return an error
if (munileft == muniright) {
if (Count(masterRoadNames) == 0) {
//Attempt to find partial matches and return in error message
var partialMatches = findPartialMatches(municipalities);
if (Count(partialMatches) == 0) return {"errorMessage" : "Match for left and right municipality not found. No partial matches found." };
return {"errorMessage" : "Match for left and right municipality not found. Partial matches: " + Concatenate(partialMatches, ", ")};
}
}
// If left and right side municipality are different, we need one record for each municipality in the table
else {
var leftmatch = null;
var rightmatch = null;
for (var road in masterRoadNames) {
if (road[mastermuni_field] == munileft) leftmatch = `${road[masterfullname_field]} (${road[mastermuni_field]})`;
if (road[mastermuni_field] == muniright) rightmatch = `${road[masterfullname_field]} (${road[mastermuni_field]})`;
}
// If either the left or the right side municipality is not found return an error
if (IsEmpty(leftmatch) || IsEmpty(rightmatch)) {
var error = "Match for left and right municipality not found. "
var search_municipalities = municipalities;
if (IsEmpty(leftmatch) && !IsEmpty(rightmatch)) {
error = "Match for left municipality not found. ";
search_municipalities = [munileft];
}
if (!IsEmpty(leftmatch) && IsEmpty(rightmatch)) {
error = "Match for right municipality not found. ";
search_municipalities = [muniright];
}
var partialMatches = findPartialMatches(search_municipalities);
if (Count(partialMatches) == 0) return {"errorMessage" : error + "No partial matches found." };
return {"errorMessage" : error + "Partial matches: " + Concatenate(partialMatches, ", ")};
}
}
return true;
The address solution has a constraint rule, you could adapt it to find the closets match to the input and fill out value:
// This rule will ensure the full name exist in the Master Road Name table
// It will compare the left and right municipality to the municipality in the Master Road Name table
// If the left and right municipality are different there will need to be a road name for each municipality in the Master Road Name table
// Define the Road Centerline fields
var fullname_field = "fullname";
var munileft_field = "munileft";
var muniright_field = "muniright";
// Define the Master Road Names fields
var masterfullname_field = "fullname";
var mastermuni_field = "municipality";
// If the fullname is blank or null return
If (!HasKey($feature, fullname_field)) return true;
var fullname = $feature[fullname_field];
If (IsEmpty(fullname)) return true;
// Get the left and right side municipalities
var munileft = $feature[munileft_field];
var muniright = $feature[muniright_field];
var municipalities = [munileft, muniright];
// This function will attempt to find partial matches in the master road name table
function findPartialMatches(search_municipalities) {
//Attempt to find partial matches and return in error message
var partialMatches = [];
var fullname_parts = Split(fullname, ' ', -1, true)
var muni_clause = mastermuni_field + " IN @search_municipalities"
if (Includes(search_municipalities, null)) {
muni_clause = "(" + mastermuni_field + " IS NULL OR " + mastermuni_field + " IN @search_municipalities)"
}
for (var i in fullname_parts) {
if (Count(fullname_parts[i]) < 3) continue;
var search_string = "%" + fullname_parts[i] + "%";
var masterRoadNames = Filter(FeatureSetByName($datastore, "MasterRoadName", [masterfullname_field, mastermuni_field], false), muni_clause + " AND " + masterfullname_field + " LIKE @search_string");
for (var road in masterRoadNames) {
var roadname = `${road[masterfullname_field]} (${road[mastermuni_field]})`
if (!Includes(partialMatches, roadname)) {
Push(partialMatches, roadname );
}
}
}
return partialMatches;
}
// Search the master road name table for a row matching the fullname and municipality
var muni_clause = mastermuni_field + " IN @municipalities"
if (Includes(municipalities, null)) {
muni_clause = "(" + mastermuni_field + " IS NULL OR " + mastermuni_field + " IN @municipalities)"
}
var masterRoadNames = Filter(FeatureSetByName($datastore, "MasterRoadName", [masterfullname_field, mastermuni_field], false), muni_clause + " AND " + masterfullname_field + " = @fullname");
// If the left and right side municipality we only need one matching record
// If no matching records are found return an error
if (munileft == muniright) {
if (Count(masterRoadNames) == 0) {
//Attempt to find partial matches and return in error message
var partialMatches = findPartialMatches(municipalities);
if (Count(partialMatches) == 0) return {"errorMessage" : "Match for left and right municipality not found. No partial matches found." };
return {"errorMessage" : "Match for left and right municipality not found. Partial matches: " + Concatenate(partialMatches, ", ")};
}
}
// If left and right side municipality are different, we need one record for each municipality in the table
else {
var leftmatch = null;
var rightmatch = null;
for (var road in masterRoadNames) {
if (road[mastermuni_field] == munileft) leftmatch = `${road[masterfullname_field]} (${road[mastermuni_field]})`;
if (road[mastermuni_field] == muniright) rightmatch = `${road[masterfullname_field]} (${road[mastermuni_field]})`;
}
// If either the left or the right side municipality is not found return an error
if (IsEmpty(leftmatch) || IsEmpty(rightmatch)) {
var error = "Match for left and right municipality not found. "
var search_municipalities = municipalities;
if (IsEmpty(leftmatch) && !IsEmpty(rightmatch)) {
error = "Match for left municipality not found. ";
search_municipalities = [munileft];
}
if (!IsEmpty(leftmatch) && IsEmpty(rightmatch)) {
error = "Match for right municipality not found. ";
search_municipalities = [muniright];
}
var partialMatches = findPartialMatches(search_municipalities);
if (Count(partialMatches) == 0) return {"errorMessage" : error + "No partial matches found." };
return {"errorMessage" : error + "Partial matches: " + Concatenate(partialMatches, ", ")};
}
}
return true;
I think this might help with what I am trying to do. Thanks.
I'm in the same situation. I opted for importing that MasterStreetName table as a .csv to create a Domain for that field.