Hi ESRI Community,
I want to caveat this by stating that I’m a complete rookie to this.
I have a drainage network layer that consists of a feature class with a field that gets populated when an inspection is created. It takes the inspection date attribute from the related table and populates the feature class with that date. The users wanted this so they could quickly look at the features' attributes and see when the last inspection was done. I have this working.
The users now want to modify the feature’s schema to have a field “LastConditionRatingInspectDate” and another field called “LastMaintenanceActivityDate”.
The inspection form has a field “InspectionReason” which gets populated, via a dropdown, with either “Condition Rating” or “Maintenance Activity”.
Based on what the field editor selects in the “InspectionReason” field, I need to have the inspection date populate the “LastConditionRatingInspectDate” if they select “Condition Rating” or the “LastMaintenanceActivityDate” if they select “Maintenance Activity”.
I was thinking an If-then-else would work. If they select “Condition Rating” then the “LastConditionRatingInspectDate” field gets populated with the inspection date, else the “LastMaintenanceActivityDate” would get populated with the inspection date.
Any help on how to make this work would be greatly appreciated!
I’m currently testing using a fgdb in Pro, however, this will be moved to Enterprise for use in web app and Field Maps.
ArcGIS Pro 2.8.8
Arc Enterprise 10.9.1
Here’s the functioning code:
var parent_id = $feature.ParentGUID
if (IsEmpty(parent_id))
return parent_id;
//On the next line, the field LastInspectionDate is the current field which would need to be changed to reflect the new field name
var parent_class = FeatureSetByName($datastore, "CTDOT_Planning_OtherDrainage", ["globalid", 'LastInspectionDate'], false);
var parent_records = Filter(parent_class, "globalid = @parent_id");
return {
'edit': [{
'className': 'CTDOT_Planning_OtherDrainage',
'updates': [{
'globalID': $feature.ParentGUID,
'attributes': {
//On the next line the, the field LastInspectionDate is the current field which would need to be changed to reflect the new field name
'LastInspectionDate': $feature.InspectionDate
}
}]
}]
}