Hi,
I have been working on a custom Arcade expression that displays a table of related inspections in the popup for a feature in ArcGIS Online Map Viewer. The code is working perfectly in the Map Viewer, but when I try to use it in ArcGIS Field Maps, I'm encountering an error (Error code 7018) that states "Arcade expression is invalid".
I've included the Arcade code below for reference:
var parentGlobalID = $feature.GlobalID;
var tbl = "<table border='1' cellpadding='5' cellspacing='0' style='width:100%; direction:rtl;'>";
tbl += "<tr style='background-color: #D3D3D3;'><th>Inspection Date</th><th>Inspector Name</th><th>Status</th></tr>";
// Get related records sorted by date
var relatedRecords = filter(FeatureSetByName($map, "Inspections", ["InspDate","InspReporterName","InspStatus"], false),
if (Count(relatedRecords) > 0) {
for (var i in (OrderBy(relatedRecords, "InspDate DESC",))) {
var rowBackgroundColor = "background-color: #CCFFCC;";
// add backround to row if InspStatus is "Not Valid"
if (i.InspStatus == "Not Valid") {
rowBackgroundColor = "background-color: #FFCCCC;";
}
// format date field to DD/MM/YYYY
var formattedDate = Text(Date(i.InspDate), 'DD/MM/YYYY');
tbl += "<tr style='" + rowBackgroundColor + "'><td style='text-align:center;'>" + formattedDate + "</td><td style='text-align:center;'>" + i.InspReporterName + "</td><td style='text-align:center;'>" + i.InspStatus + "</td></tr>";
}
} else {
tbl += "<tr><td colspan='3'>Inspections not found</td></tr>";
}
tbl += "</table>";
return {
type : 'text',
text : tbl //this property supports html tags
}
Has anyone encountered a similar issue or has insights on what might be causing this error specifically in ArcGIS Field Maps? Any help or suggestions would be greatly appreciated.
Guy Nizry