Good morning,
New to Arcade and was able to borrow and modify this statement from others to pull last date returns from related tables.
Background: This is used to pull last dates from two different tables and display them in the a popup, one table is for collections, the other is for assessments. This data is used in field to record garbage collection activities and assess overall cleanliness of a stretch of road.
What it does: The script looks at the table, find the last record date of a selected segment and if none found, return the text "none to date".
Issue: As you can see from the screen shots attached, It works like a champ for the collections table but not for the assessment table and not sure why. (tables and images attached for reference)
Only noticeable difference in the tables (to me): The collection table has finish and start date fields and attachments enabled whereas the collection table only has a single date field and no attachments. Layer and tables were created, related and shared to AGOL via ArcMAP.
COLLECTION
var relRec = orderby(FeatureSetByRelationshipName($feature,"Collections"), "FinishTime DES");
var cnt = Count(relRec);
var relatedInfo = "";
if (cnt>0) { var info = First(relRec);
relatedInfo = Text(ToLocal(info.FinishTime),"MM/DD/Y");
} else var relatedInfo="None To Date";
return relatedInfo;
ASSESSMENT
var relRec = orderby(FeatureSetByRelationshipName($feature,"Assessments"), "AssessDate DES");
var cnt = Count(relRec);
var relatedInfo = "";
if (cnt>0) { var info = First(relRec);
relatedInfo = Text(ToLocal(info.FinishTime),"MM/DD/Y");
} else var relatedInfo="None To Date";
return relatedInfo;
Scratching my head...