Update a single entry in a Feature Class

350
4
Jump to solution
02-05-2019 03:12 PM
JacobHolcombe
New Contributor

I am trying to update a single entry in a feature class with new data from a work order. I have a feature class that contains all of the meter's in within an area. When the crew goes out into the field and change out a part they bring me a work order with the new serial number, model etc. Is there a way in model builder to select the single entry to be modified and update it with these new values? So far the only method I have come up with was to create a new feature class with the Select tool, then using the Calculate Field tool update each field. The problem has been getting this data back into the source feature class. I was trying to avoid a situation where I delete the old record and append the newly created one if possible. 

0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

All tools honour a selection, this is basic GIS. So select your row first using the select by attribute tool then run the field calculate tool on the field you want to update. The update will only apply to the selection.

Be aware that if your initial selection fails, for example they have returned an incorrect serial number then when you run the calculate field tool it will overwrite everything as there is no selection and there is NO UNDO for that action.

You should not be exporting, editing and then importing that is simply inefficient.

Suggest you create some test data and explore this approach before you apply it to your operational data.

View solution in original post

4 Replies
DuncanHornby
MVP Notable Contributor

All tools honour a selection, this is basic GIS. So select your row first using the select by attribute tool then run the field calculate tool on the field you want to update. The update will only apply to the selection.

Be aware that if your initial selection fails, for example they have returned an incorrect serial number then when you run the calculate field tool it will overwrite everything as there is no selection and there is NO UNDO for that action.

You should not be exporting, editing and then importing that is simply inefficient.

Suggest you create some test data and explore this approach before you apply it to your operational data.

TedKowal
Occasional Contributor III

....ps... if you turn on editing then you undo the calculate tool ..... but you will have to remember so save edits for the changes to take.

0 Kudos
JacobHolcombe
New Contributor

Ok this makes sense. I think I was going the export/build/import route to avoid that exact risk of overwriting everything. In another script I have used the Get Count tool after the Selection tool which I then feed into the Stop (When inputs are false) tool to help prevent the above mentioned possibility. If each value is supposed to be unique then I should only return either a 0 or a 1.

Is this an adequate method of trying to avoid that scenario or is there another better method of preventing that?

DuncanHornby
MVP Notable Contributor

Absolutely. I have also used the Get Count as a precondition to stop the flow of logic rather than stop the whole model. If you are willing to try model builder in ArcGIS Pro then there is an If Selection Exists tool to control work flow.