I am trying to calculate a field in field maps using the arcade expression.
I have a parent/child relationship and I need to pull the last recording date to populate a field on the new record created.
Here is what I have, and it is currently not working. What am I missing in my expression?
//Fetch the related inspections from the related table using the relationship name
var inspections = FeatureSetByRelationshipName($feature, "Corrosometer_Probe_Data_Records", ["Read_Date"], false);
//Sort inspections by the read date in descending order to get the most recent
var sortedInspections = OrderBy(inspections, "Read_Date DESC");
//Get the first (latest) inspection date
var latestInspection = First(sortedInspections);
//If there are previous inspections, get the date of the latest inspection
if (!IsEmpty(latestInspection)) {
return latestInspection["Read_Date"];
} else {
//If no previous inspections exist, return null or a default value
return null;
}
Thanks for any help!