Add Field (small integer)

197
4
Jump to solution
2 weeks ago
Labels (1)
CarsonMorton
New Contributor III

When I look at my existing fields, I have a couple with the type as "Small Integer"

However when I try to add a new field it does not give me the option for a "Small Integer". I see "Big Integer" and regular "Integer"

I can work around this by making the changes locally and republishing, but I am hoping that there is a simpler way to do it directly online.

 

NOTE: the solution says to drill down into the layer before clicking on Admin. I had to do it the other way around because Admin would disappear when I had clicked on the layer name. But it did work in the end!

0 Kudos
1 Solution

Accepted Solutions
MobiusSnake
MVP

If I need to add a small integer field to a service, I usually do so using the REST services directory's admin page.  In case you haven't used this before, you can do this:

  • On the service's item page, look for the "URL" section in the lower right and click the launch button.  This should open a simple HTML page with a title of "Your_Service_Name (FeatureServer)".
  • Under the Layers list, click the layer you want to add the field to, this will open a new page.
  • From here, click the Admin link in the upper right.  This will open a new page with a different-coloured header.
  • From here, click on the Add to Definition link at the bottom this will give you a new page with a large text box that has a bunch of JSON in it.
  • "Select all" on the text box's contents and delete it.
  • Enter something like this (replacing names and aliases as necessary) and click the "Add to Layer Definition" at the bottom:
{"fields": [{
  "name" : "MyNewField", 
  "type" : "esriFieldTypeSmallInteger", 
  "alias": "My New Field",
  "nullable": true, 
  "editable" : true, 
  "visible" : true
}]}

 

You should get a page saying the operation was successful and your new field should be on the layer.

View solution in original post

4 Replies
MobiusSnake
MVP

If I need to add a small integer field to a service, I usually do so using the REST services directory's admin page.  In case you haven't used this before, you can do this:

  • On the service's item page, look for the "URL" section in the lower right and click the launch button.  This should open a simple HTML page with a title of "Your_Service_Name (FeatureServer)".
  • Under the Layers list, click the layer you want to add the field to, this will open a new page.
  • From here, click the Admin link in the upper right.  This will open a new page with a different-coloured header.
  • From here, click on the Add to Definition link at the bottom this will give you a new page with a large text box that has a bunch of JSON in it.
  • "Select all" on the text box's contents and delete it.
  • Enter something like this (replacing names and aliases as necessary) and click the "Add to Layer Definition" at the bottom:
{"fields": [{
  "name" : "MyNewField", 
  "type" : "esriFieldTypeSmallInteger", 
  "alias": "My New Field",
  "nullable": true, 
  "editable" : true, 
  "visible" : true
}]}

 

You should get a page saying the operation was successful and your new field should be on the layer.

CarsonMorton
New Contributor III

I may have deviated slightly, here is how and why:

  • There was no URL in "My_Layer - Service Definition", so I went to "My_Layer - Feature Layer (hosted)" instead. Clicking "View" on the URL did take me to the "My_Layer (FeatureServer)" page.
  • I didn't go into the Layers list because this is the layer I want. (no sublayers) and the Admin link was already in the top right.

Everything else seemed correct, but it didn't seem to work. unless it takes a while to propagate the change?

0 Kudos
MobiusSnake
MVP

The change should be immediate, no time to propagate.

There are two "Add to Definition" pages, one that is used to modify the service and one that's used to modify a specific layer or table within the service.  It sounds like you got the wrong one; the service-level one would be used to do something like add a new sublayer or table to the service (you can do all sorts of cool things through these interfaces that you can't do through the standard web interface), whereas the layer/table-level one is what you need to call to add a field or an index.  If you tried to add a field at the service level, I expect nothing would happen but it wouldn't give you an error, either.

If your service only consists of one layer, you should still go down to the sublayer page; otherwise you're working with the service and not a layer.

0 Kudos
CarsonMorton
New Contributor III

Finally got back to this.

What threw me off was that I had to click admin before clicking on the layer. If I clicked the layer first, then the Admin link would disappear.

So it worked. Thanks!

Also now I have to dig into this REST stuff and see what other nifty tricks can be done with it!

0 Kudos