1

I could use some assistance creating a calculation that just simply pulls attribution from a field in one feature class, and populates the edited result into another feature class's table. For example:

We have a streets layer named 'Streets' with a field [StreetName]. When that table gets edited, the result should ideally just get updated in the other layer named 'New_Streets', but in a field called [NAME]. If these fields are in the same table - it works okay using this code:

var features = $feature.NAME

if ("$feature.StreetName" == "Null") {return false}

return features

I would like to be able to do this using two layers in the same geodatabase.

1 Answer 1

1

You have not provided enough detail about the relationship of your layer Streets to New_Streets, thus I have to make an assumption that New_Streets is a copy of Streets. I say this as the solution I offer below requires a one-to-one match with the ObjectID field, so row 1000 in Streets is the same street as row 1000 in New_Streets.

So your data should look as below:

Input data

For this attribute rule to work you need to set an immediate calculation to trigger on UPDATE for the Street layer. I show the setting of the rule below:

Rule

The expression is this:

// Get updated name and ObjectID
var updatedName = $feature.StreetName;
var OID = $feature.OBJECTID;

// create a dictionary that holds the instructions to update New_Streets
var resultDict = {'edit':[{'className': 'New_Streets','updates':[{'objectID':OID,'attributes':{'Name':updatedName}}]}]};

// Returning dictionary executes update
return resultDict;

Note: for some reason I had to enable GlobalID for it to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.