I have a map that shows international submarine cables and their landing points around the world. I have a standalone table added to my map that lists all the landing points and what cables they are associated with like so:
My list of landings is unique City/State/Country names and it's possible for more than one cable system to come to a single landing. What I want to do - and I think I have all the correct tables and data needed for this - is to create an attribute expression so that when someone clicks on a Landing Point it shows all the Cable Systems associated with that landing. Fortaleza, for instance, is associated with 14 cable systems.
I was able to do something similar in ArcGIS Pro using a Relate but I'm trying to figure out how to do the same thing in my web map. Basically what I need to do is match the "Name" field from my Landing Points layer to the "Cable_Landings_Export.City" field in my standalone table and then add all the cable system names from the "All_Cables_Table_Export.SystemName" field as a list, preferably bulleted or something and not a comma separated list.
I'm not a coder so I'm a little lost trying to work with Arcade and not sure where I should even start.
Sorry... line 15 before "txt" is should say "var txt"...
So
var txt = TextFormatting.NewLine etc etc?
Dangit, still complaining about undeclared variables.
I really appreciate you taking the time to help me with this.
Got it working! The "record" variable was undeclared. This code now works:
var cityname = $feature["STF_Cable_DBO__tblLanding_City"]; // read out the city
var sql = "Cable_Landings_Export_City" + " = '" + cityname + "'"; // create query
var table = FeatureSetByName($map, "subcablemapbackup_gdb - LandingPlusCableTable"); // get access to table
var related_records = Filter(table, sql); // filter the table for relevant records
var record = "All_Cables_Table_Export_SystemN";
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 (record in related_records) {
var txt = TextFormatting.NewLine + " - " + record.All_Cables_Table_Export_SystemN; // use the correct field name from the table
result += txt;
}
}
return result;
Thank you so much for your help!
Good catch kclark_SubTelForum ,
Although I would prefer doing this (see line 15):
var cityname = $feature["STF_Cable_DBO__tblLanding_City"]; // read out the city
var sql = "Cable_Landings_Export_City" + " = '" + cityname + "'"; // create query
var table = FeatureSetByName($map, "subcablemapbackup_gdb - LandingPlusCableTable"); // 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.All_Cables_Table_Export_SystemN; // use the correct field name from the table
result += txt;
}
}
return result;
Glad it works!