Use JSON to set "nullable" : false

2917
9
Jump to solution
02-01-2017 11:33 AM
TomKearns
Occasional Contributor II

I am trying to set a few fields to required using JSON to update a layer in a hosted feature service. I have

"nullable" : false,

but when I update the layer it never makes the change.  I have made other changes successfully in the past, to this same service.  Is there another spot that needs to be edited for this change to stick?

I published a second service to try and see the differences but was unable to glean anything from it.

Thanks.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KellyGerrow
Esri Frequent Contributor

Hi Tom,

Thanks for following up and I apologize for the slow reply. The update definition call only supports updates to the domain and alias fields. Modifying the nullable property and editable property for an existing field is not possible through the JSON.

As a workaround, you can create a new field with the desired properties, Use the add to definition call and specify that the field is not-nullable. You can then use the calculate API to move the values from the field with the incorrect settings.

Sample JSON for add to definition:

{"fields":[{"name":"testfiled","type":"esriFieldTypeString","alias":"not Nullable","nullable":false,"editable":true,"length":256,"defaultValue":"250"}]}

-Kelly

View solution in original post

9 Replies
KellyGerrow
Esri Frequent Contributor

Hey Tom,

How are you submitting the edit? Through the rest endpoint? Can you share the specific workflow that you are following?

-Kelly

0 Kudos
TomKearns
Occasional Contributor II

Hi, thanks.  I am submitting the edit using the 'update definition' the rest in rest/admin/service.  I have no problems updating domains or other items in this manner but when I try the nullable it states: Updated Feature Service Layer: name  but if I click through on the layer name it shows nothing was changed.  My JSON is good, I use JSONLint but it shouldn't really be necessary in this case since I am just changing a true to false.  

I also hosted a new featureclass with a nullable: false and cannot change its status to true.  So I cant alter the status in either direction.

0 Kudos
TomKearns
Occasional Contributor II

Related, I cannot update the field name either. I can add a selection to a domain and that seems like it.  I feel like all of this should be possible with the JSON. 

0 Kudos
KellyGerrow
Esri Frequent Contributor

Thanks Tom,

Will research this and get back to you!

TomKearns
Occasional Contributor II

Hi Kelly,

I was wondering if there was any progress on this issue?  It would be very helpful to not have to repost a service for every small change.

Thanks!

0 Kudos
KellyGerrow
Esri Frequent Contributor

Hi Tom,

Thanks for following up and I apologize for the slow reply. The update definition call only supports updates to the domain and alias fields. Modifying the nullable property and editable property for an existing field is not possible through the JSON.

As a workaround, you can create a new field with the desired properties, Use the add to definition call and specify that the field is not-nullable. You can then use the calculate API to move the values from the field with the incorrect settings.

Sample JSON for add to definition:

{"fields":[{"name":"testfiled","type":"esriFieldTypeString","alias":"not Nullable","nullable":false,"editable":true,"length":256,"defaultValue":"250"}]}

-Kelly

TomKearns
Occasional Contributor II

Thank you for chasing this down.  The workaround should be sufficient.  I have not re-ordered the fields in AGOL but I suspect it is possible.

Just a note on the example, "editable":True, needs to have a lowercase true.  Straight copy paste won't work.

Thanks!

0 Kudos
KellyGerrow
Esri Frequent Contributor

Thanks Tom,

I updated the text in the sample I have!

0 Kudos
deleted-user-LNABNwA5CZcD
New Contributor III

I'm hitting the same issue. So, the Field name itself cannot be changed, either? I really need to change "nullable" from false to true for a certain field. I have a hosted feature layer being populated by a native phone app. I'm OK losing current data. Would it not work to change "PollutionCounty" to "PollutionCounty1" and then create a new nullable "PollutionCounty"?

0 Kudos