Select to view content in your preferred language

Update Field in Related Feature Class when Creating New Records in Related Table

a month ago
New Contributor III

Hello all,

We are trying to incorporate new attribute rules to streamline different updates. One of them is updating the "Last_Asmt" field in our feature classes upon creating new records in their related assessment table.


// Extract the first value from the key field
var keyFieldValues = ($feature['FacilityID']);
var firstValue = keyFieldValues[0];

// Determine the relationship class based on the first value
var relationshipClass;
if (firstValue == 'D') {
    relationshipClass = 'Stormwater_Training.STORM_ADMIN.DS_has_Asmt';
} else if (firstValue == 'E') {
    relationshipClass = 'Stormwater_Training.STORM_ADMIN.ES_has_Asmt';
} else if (firstValue == 'W') {
    relationshipClass = 'Stormwater_Training.STORM_ADMIN.WS_has_Asmt';
} else if (firstValue == 'N') {
    relationshipClass = 'Stormwater_Training.STORM_ADMIN.NS_has_Asmt';
} else if (firstValue == 'O') {
    relationshipClass = 'Stormwater_Training.STORM_ADMIN.OC_has_Asmt';
} // Add more conditions as needed

// Get the related records from the determined relationship class
var relatedRecords = FeatureSetByName($datastore, relationshipClass, [$feature]);

// Populate the related feature class with the current timestamp
var currentTime = Now();
relatedRecords[0]['Last_Asmt'] = currentTime;

// Return the updated related records
return relatedRecords;


When trying to validate the expression I'm met with errors that a string is expected in Line 21. I've updated that to show the fully qualified database name (though I have other attribute rule expressions that do not require this) and I'm then prompted with an error for an expected feature set collection. Any help on this would be greatly appreciated. 

0 Kudos
0 Replies