I went through many of the posts that deal with populating a parent feature with a value from related child table but still can't get mine to work.
I have a BankErosionPoints Feature Layer. I have a related child inspection table named BankErosionPtInspection. A user create a point when they find an erosion area along a shoreline. During various monitoring events they observe the eroded area to determine if it is still eroding or if is stable. The user then updates the Status field of the child table with Eroding or Stable. I want that value to be passed to the parent Erosion Point field StatusParent so that the erosion point status is kept updates as to the status of the erosion based on the inspections in the child table. My parent feature and child inspection table are related by GlobalId and BankERoPtInsp_GUID fields.
I have placed this calculated expression in the StatusParent field in the Smart form for the BankErosionPoints parent feature layer. However, my StatusParent field in the parent layer is never updated. Does anyone know what I am doing wrong? Thank you!!!
var AllReads = FeatureSetByName($map, "BankErosionPtInspection");
var ParentGlobalID = $feature.GlobalID;
var sql = "BankEroPtInsp_GUID = '" + ParentGlobalID + "'";
var RelatedReads = Filter(AllReads, sql);
var numrelreads = Count(RelatedReads);
if (numrelreads == 0) {
return Null;
} else if (numrelreads != 0) {
// Find the most recent related record
var LastRelRead = First(OrderBy(RelatedReads, "CurrentReadDate DESC"));
// Get the Status from the most recent related record
var statusFromChild = LastRelRead.Status;
// Update the parent feature's StatusParent field with the value from the child record
return statusFromChild;
}