auto-populate fields when adding related records

4033
5
07-20-2015 02:16 PM
Highlighted
New Contributor III

Someone asked a similar question here with no replies so I'll ask it again in a different way.

Is it possible to auto-populate a field (in addition to the unique ID) from a parent feature service to a related record?

I currently have my unique ID auto-populating when creating new related records but I would like other fields to transfer to my related record as well. For example, I would like the manhole # and the serial # of the monitor to transfer from the original point feature service to the related table (maintenance records). Auto-populating fields would save the field-guys from typing this info over and over.

Capture.JPG

I've experimented with a few varieties of relationship classes without success. Any ideas would be great. Thanks

Message was edited by: Caleb Anderson

Contacted ESRI and was told by support that this is not possible

Message was edited by: Caleb Anderson

The best I could come up with for a workaround (after deep-diving into some other forums) is to move the data from the cloud to our local SDE. Our main brain GIS people will make the data available for collector and field collection work-flows will continue as usual. With the data stored locally, I can automate the following tool to "auto-populate" specified fields (field personnel leave the field blank and the tool runs nightly and replaced null values with data from a parent feature class field):

SN_Fix.PNG

The "Calculate Field" in the above model builder tool has the following script:

Capture.PNG

I tried it out locally and it works but I haven't tried it through our SDE yet. There will have to be some coordination to make this happen but I don't see why it wouldn't work.

5 Replies
Highlighted
New Contributor III

I also would like to do this - preferably on AGOL

Highlighted
Occasional Contributor

How can this be done???

Reply
0 Kudos
Highlighted
Esri Contributor

Hello,

I've recently come across this issue myself and found a github that populates a parent FC from a populated related within ArcGIS Pro's Attribute Rules: arcade-expressions/UpdateParentFeature.md at master · Esri/arcade-expressions · GitHub 

With a little tweaking I was able to reverse this to populate the related attribute table when populating the parent FC:

// This rule will update an attribute in the child table
// Build a relationship class from the Feature Class (origin) to the Table (foreign) based on GlobalID
// Store the child table globalID from the key field in the relationship class
var childGlobalID = $feature.ChildGlobalID;
if (IsEmpty(childGlobalID))
    return childGlobalID;

// force to upper as the sql is case sensitive
childGlobalID = Upper(childGlobalID);

// Using the GDB name, get the parent classes records and Global ID field
var child_class = FeatureSetByName($datastore, "DBname.owner.TableName", ["GlobalID", 'ChildTableFeatureName'], false);
// Filter the parent class for only related features
var parent_records = Filter(child_class, "globalid = @childGlobalID");

var updates = [];
var i = 0;
var new_value = 'UpdatedFieldValue';

// Loop through each  feature, create a dict of the Global ID and the new value date
for (var row in parent_records) {
    // If the parent row is null or has a different value, updated it
    if (IsEmpty(row['ChildTableFeatureName']) || row['ChildTableFeatureName'] != new_value)
    {
        updates[i++] = {
            'globalid': childGlobalID,
            'attributes': {"ChildTableFeatureName": new_value}    
        };
    }
}

// Return the original value in the result parameter, as to not lost the entered value
// Using the edit parameter,  return the class and list of updates
return {
'result': childGlobalID,
'edit': [
            {'className': 'DBname.owner.TableName',
             'updates': updates
            } 
        ]
};

I have not been able to get this working for AGOL yet but I am trying. 

Highlighted
Esri Contributor

Brady Ross support for attribute rules is currently limited to ArcGIS Enterprise feature services.

Reply
0 Kudos
Highlighted
Esri Contributor

Aha! Thanks Doug Morgenthaler‌! 

Reply
0 Kudos