Hello,
I am attempting to format a pop-up using arcade in ArcGIS Pro 3.4.2 to return results from a related table. The use case is to create a popup of Permits on an Address.
Feature Layer = MasterAddress
Table = test_EnerGovProd_PERMITS
There is a 1:M relationship that is returning results.
Results as shown below:
ArcPro Relate:
Arcade Script Console from MasterAddress Popup
Actual ArcPro Popup:
ArcPro PopUp Script:
// Reference the permits table (double-check the name matches in the map)
var permits = FeatureSetByName($datastore, "test_EnergovProd_PERMITS", ["MAIN_ADDRESS_LINE1", "PERMIT_NUMBER"], false);
// Check if permits table loaded correctly
if (IsEmpty(permits)) {
return "Permit table not found.";
}
// Get this feature's full address
var address = Upper(Trim($feature.Address_Full))
console("address: " + address)
// Filter permits where MAIN_ADDRESS_LINE1 matches the address
var relatedPermits = Filter(permits, 'MAIN_ADDRESS_LINE1 = @address');
// Initialize an array to hold permit numbers
var permitList = [];
// Loop through matching permits and add to array
for (var p in relatedPermits) {
Push(permitList, p.PERMIT_NUMBER);
Push(permitList, p.MAIN_ADDRESS_LINE1);
}
console("relatedPermit: " + Count(relatedPermits))
//console("relatedPermit: " + relatedPermits.MAIN_ADDRESS_LINE1)
console("permitList: " + permitList)
// If permits were found, return as comma-separated string
if (Count(permitList) > 0) {
return Concatenate(permitList, TextFormatting.NewLine);
}
// If no permits found, still return a string
return "No permits found";
Any help in why the popup is not returning any values, would be apprecaited.
I have also attempted to use the following with the same result.. I am getting a console return, but nothing in the actual popup..
var related_table = FeatureSetByName($datastore, "test_EnergovProd_PERMITS", ["MAIN_ADDRESS_LINE1", "PERMIT_NUMBER"], false);
var filter_query = "MAIN_ADDRESS_LINE1= '" + $feature["Address_Full"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);
var output = []
if (related_data_filtered_count > 0) {
for (var related_data_row in related_data_filtered) {
Push(output, related_data_row.PERMIT_NUMBER)
}
} else {
return "No Related Records."
}
console (related_data_row)
return Concatenate(output, ', ')