Notebook update all features?

934
11
Jump to solution
02-02-2023 11:18 AM
Labels (2)
DamonBreen
New Contributor III

All,

I'm creating my first notebook, and following a guide on adding new features I found online. Modeling after that a bit, I think I'm most of the way there, but i'm missing something. I'm not a programmer, I just learn things as I have a need, so please keep that in mind. 

I have an inspection map that has over a thousand features, and some of these features need to be inspected once a month, others every 6 months, and others once a year. For right now, I am dealing with a dataset that has 4 features in it to test functionality. These get inspected once a month, and the field user updates a field to keep track of the features inspections. I'd like these to reset each month automatically. Here is what I have so far:

item = gis.content.get("7e781f27da1a4c9f9967a777910383fd")
RectifierLayer = item.layers[3]
UpdatedStatus = "Not Completed"
RectifierDict = {"attributes": {"Completed": UpdatedStatus}}
UpdateRectifier = RectifierLayer.edit_features(updates=[RectifierDict])
print(UpdateRectifier)

and here is the result I am getting

{'addResults': [], 'updateResults': [{'objectId': -1, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': 'Must declare the scalar variable "@OBJECTID".'}}], 'deleteResults': []}

My assumption is that since I followed a tutorial on adding a new feature, and I am trying to edit an existing one, I need to specify which feature to update, but I want to update one field in all features. Maybe I am wrong on that. I know the item ID is correct, the layer number is correct, and I think most of the syntax is correct. I have a lot of uses for notebooks, and have always been intimidated by creating them, but needed a simple task to get involved with them. I appreciate any input I will get. Thanks !

0 Kudos
11 Replies
DamonBreen
New Contributor III

Okay, so it sounds like for future reference I need to pull up the index within notebooks to identify the actual order of the layers. The example I followed made it seem like the id was what I was interested in. Sometimes I know just enough to get me in trouble. 

 

Thanks for all of your help!

DamonBreen
New Contributor III

I also tried to go back to the 1st bit of code using the edit.features function, and input the objectID of one of the records as a parameter, just to see if I could get something to work, and it was successful according to the printout, but my data in the table did not change. I wondered if that may tie into the problem here. For what its worth, I am an admin on the organization, but I did not author the map. I would assume that wouldn't matter, but thought I would mention that as well.

0 Kudos