I thought that might be the issue too, but updating the expression to this:
var asset_id = $feature.GlobalID
var relatedTable = FeatureSetByName($map, "Tree Inventory Form",['Maintenance_Performed','Date','TreeInv_Rel']);
var sortedTable = OrderBy(relatedTable, 'Date DESC')
var onlyRemoved = Filter(sortedTable,'Maintenance_Performed = "Removal"');
var relatedRecord = First(Filter(onlyRemoved, "TreeInv_Rel = @asset_id"))
console ("Related Record:",relatedRecord)
var recordDate = relatedRecord.Date
var maintPerformed = relatedRecord.Maintenance_Performed
console ("Record Date: ",recordDate,TextFormatting.NewLine,"Maintenance performed: ",maintPerformed)
if(relatedRecord == null) {
return
}
else if (!isEmpty(recordDate) && maintPerformed == 'Removal'){
return Text(recordDate,'MMM DD, YYYY')
}
else if(isEmpty(recordDate) && maintPerformed == 'Removal'){
return ' an unrecorded date'
}
else {
return
}
gives me the error with no indication of where it's coming from (though presumably the new filter statement somehow):
Expected "'", "(", "+", "-", "@", "CASE", "DATE", "EXTRACT", "FALSE", "INTERVAL", "N'", "NULL", "POSITION", "SUBSTRING", "TIMESTAMP", "TRIM", "TRUE", "`", [ \t\n\r], [0-9], or [A-Za-z_\x80-] but "\"" found.