Select to view content in your preferred language

Update field in all feature which match value

691
10
01-23-2025 04:15 AM
JamesMitchell8
Occasional Contributor

Hi all,

I would like to be able to update all the features which have the same attribute. For example, all features that has a field 'ID' with value 1, i would like all the features to have the field 'Result' updated with 'Yes' when a 'Yes; is entered into 1 feature.

I believe i need to filter the layer but i cant work out how to do this. 

Any help would be greatly appreciated.

 

0 Kudos
10 Replies
ZachBodenner
MVP Regular Contributor

Are you planning to do this using attribute rules, or a field calculator? An attribute rule might look like 

var i = $feature.ID
var r = $feature.Result
// if ID is 1, enter 'Yes' in result, otherwise leave empty)
var resultValue = When(i==1,'Yes','')
return resultValue

If you want to use a field calculator, you would do a Select by Attribute:

WHERE ID = 1 (or, WHERE ID 'is equal to' 1)

Then your attribute table will have only 1's selected, and you can run your field calculator and enter 'Yes' into the value box. 

Happy mapping,
- Zach
0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

The other question is are you talking about different features within the same feature class or the same ID in multiple feature classes. If it is the first then a field calculation using @ZachBodenner solution would work.

A simpler way to write @ZachBodenner attribute rule is:

iif( $feature.ID == 1 && $feature.Result != 'YES' , 'YES' , $feature.Result )

But that is assuming that you simply don't want any changes, otherwise you can change $feature.Result to NULL or whatever returned value you want in its place.

If it is the latter then you would need to use an attribute rule for a python script to accomplish that.

0 Kudos
JamesMitchell8
Occasional Contributor

Hi,

Thank you, i would like to do this in field maps. When one record 'Result' is updated, i want all the other features 'Result' field to update too where ID = 1.

0 Kudos
ZachBodenner
MVP Regular Contributor

You should absolutely be able to do this in Field Maps. In your form designer, click on the Results atteibute and click calculated expressions. Here's an example from an app of mine:

ZachBodenner_0-1737645672333.png

Then you can basically use the same code that either myself or @RPGIS provided.

Happy mapping,
- Zach
0 Kudos
JamesMitchell8
Occasional Contributor

Hi Zach,

I don't understand how that will update all the features in the feature layer which have an id of 1? It looks like it only updates the current feature.

 

Thank you

James

0 Kudos
ZachBodenner
MVP Regular Contributor

Oh I see what you're saying here. So in Field Maps, this will affect all future additions to the dataset. If you need to do it in batch, then @RPGIS is right, you can't do that in Field Maps and you'll need to use the Field Calculator.

Happy mapping,
- Zach
0 Kudos
JamesMitchell8
Occasional Contributor

I want it to update all the features in the dataset at the same time when a value is entered in the form. I tried using the calculate field but i cant use arcade due to sync and i doint know how to do this in SQL either. I dont even know if this will run all the time or if it just a one off calculation.

 I will have to create a python script as a scheduled task

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

What kind of versioning are you using if you are using any at all.

It sounds like you are using batch versioning which would require that you to disable the service, delete the version possibly, apply the edits/create the attribute rule, and then re-publish the service.

We are using traditional versioning since we have a lot of back end processes that run in SQL so I am a little unfamiliar with the batch versioning.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

This capability must have been added for Enterprise releases 11.0 and later. We are currently using 10.9.1 which is why I originally thought it wouldn't work. I suppose with later updates that this will be possible.

0 Kudos