In the old Desktop Attribute Assistant, you could create multiple rules:
Create a rule to generate incremental sequential IDs (Max + 1) based on the last generated ID (the generated ID starts at 1000).
Copies a series of values from the nearest feature in a specified layer.
In the screenshot, you can see how the rules are defined in ArcMap/Attribute Assistant. I've tried several codes in Attribute Rule without success. How can I achieve these actions in ArcGIS Pro?"
For the IDs, see my answer in this question: https://community.esri.com/t5/arcgis-pro-questions/using-attribute-rules-to-create-sequential-id/m-p...
For returning the nearest feature's attributes, you could do something like this:
// Calculation Attribute Rule
// field: empty!
// triggers: Insert, update
var other_fc = FeaturesetByName($datastore, "Etages")
var search_dist = 1000
// get all features in other_fc within search distance
var other_near = Intersects(other_fc, Buffer($feature, search_dist))
// find the nearest
var min_dist = search_distance
var other_nearest = null
for(var f in other_near) {
var dist = Distance($feature, f)
if(dist < min_dist) {
other_nearest = f
min_dist = dist
}
}
// abort if no feature was found in the search distance
if(other_nearest == null) { return }
// copy the attributes
return {
attributes: {
EtaID: EtaID,
EtaCode: EtaCode,
NivCode: NivCode,
}
}
Hello, I would like to thank you for responding to my request so quickly and for the solution provided. I have encountered an issue with this code on my map, as it doesn't seem to recognize the "Etages" layer. Could you please let me know the possible reason for this?
Attribute Rules don't work with layers in maps, they work with featureclasses/tables in the same database.