I have created a 1-to-many relationship class between a feature class (Structures) and a related table (Inspections) and published to ArcGIS Online. Each Structure will have many Inspection records created over time.
When the user clicks to create a new Inspection record for a Structure (eg. in Field Maps or Map Viewer), I want the new Inspection record to be prepopulated with some of the attribute values from the most recent Inspection record for that Structure, but haven't been able to get this to work.
Using FeatureSetByRelationshipName, I am able to pull attribute information from the most recent Inspection record into the parent Structure (and vice-versa). eg. the following Arcade expression sorts into date order all of the previous Inspections for a Structure and pulls from the most recent Inspection its inspection date and inspection notes, which I can display as text in the Pop-up or Edit form for the parent Structure:
var relatedRecords = OrderBy(FeatureSetByRelationshipName($feature, "Inspections"), "Last_Inspection_Date_ DESC");
var cnt = Count(relatedRecords);
var myLastInspectionDate = "";
var myInspectionNotes = "";
if (cnt > 0) {
var info=First(relatedRecords);
myLastInspectionDate = Text(info.Last_Inspection_Date_, "MM/DD/Y");
myInspectionNotes = Text(info.Inspection_Notes_);
}
return myLastInspectionDate + " - " + myInspectionNotes;
The above approach has been covered numerous times on various forum answers, blogs and videos but can anyone advise how to get that same attribute information to either prepopulate the fields in a new Inspection record, or at least display it as text somewhere on its Edit form?