So I originally had this solved through this thread: Custom Attribute Expression in ArcGIS Online to Show Related Table Information but since then I have learned a lot more about ArcGIS and have changed the way things are structured in my web map. I'm having trouble getting the Arcade expression updated to do the same thing. The following code produces the pop up information I want in ArcGIS Pro, but does not work once the map is published to the web:
var cityname = $feature.City; // read out the city
var sql = "tblLanding_EXPORT.City" + " = '" + cityname + "'"; // create query
var table = FeatureSetByName($map,"LandingsWithCables_EXPORT"); // get access to table
var related_records = Filter(table, sql); // filter the table for relevant records
var cnt = Count(related_records); // determine the number of records found
var result = "";
if (cnt == 0) {
// no records found
result = "No cable systems found";
} else {
// we have related records, let's create the text to return
result = cnt + " cable system(s) found:";
for (var record in related_records) {
var txt = TextFormatting.NewLine + " - " + record.SystemName; // use the correct field name from the table
result += txt;
}
}
return result;
The web map can be found here: https://arcg.is/1vSTTC0
I think it's just a matter of getting the right variable/field/table names but for the life of me I can't figure out why it's not working when the map is put online. Any insight would be greatly appreciated.
Try removing "tblLanding_EXPORT.
" in line 2 so it says
var cityname = $feature.City; // read out the city
var sql = "City" + " = '" + cityname + "'"; // create query
var table = FeatureSetByName($map, "LandingsWithCables_EXPORT"); // get access to table
var related_records = Filter(table, sql); // filter the table for relevant records
var cnt = Count(
related_records); // determine the number of records found
var result = "";
if (cnt == 0)
{
// no records found
result = "No cable systems found";
}
else
{
// we have related records, let's create the text to return
result = cnt + " cable system(s) found:";
for (var record in related_records)
{
var txt = TextFormatting.NewLine + " - " + record.SystemName; // use the correct field name from the table
result += txt;
}
}
return result;
That was exactly it, thank you for catching this. I streamlined how a lot of my tables and references work so I missed this one. Thanks!