Default values for dates

2859
4
05-06-2020 10:07 AM
RenRosin
New Contributor III

Mike Minami  have been following the thread about default values in ArcGIS online, and would like set the default value of a date field in a feature service. It currently defaults to 12/29/1899. When I go to the fields tab in Arcgis Online, for the default value, it says "Invalid Date" and doesn't allow me to edit it. Can I edit it in json?

What should the json look like for "Today's Date"

This is what it currently looks like:

 {       "name" : "Date_new",        "type" : "esriFieldTypeDate",       "alias" : "DATE_New",        "sqlType" : "sqlTypeOther",        "length" : 8,        "nullable" : true,        "editable" : true,        "domain" : null,        "defaultValue" : "-2209161600000",        "description" : "{\"value\":\"\",\"fieldValueType\":\"dateAndTime\"}"     }


Tags (1)
4 Replies
MikeMinami
Esri Notable Contributor

If I understand your question correctly, it seems like you want the default date to be set to "today" such that when new features get added, they're added with the current date. If this is what you want, we don't support relative dates like this as default values as far as I know.

Additionally, I will add that the AGOL UX doesn't let you change the default value on existing fields (via the Data>Fields tab). If you add a new field, you can set a default. The default value is maintained on the feature service itself. I don't know if the feature service REST API supports changing the default value on the server. If you publish from Pro, you can configure default values before publishing.

To support creating new features, ArcGIS does support Feature Templates. Feature templates provide a way to add particular types of features. For example, say you have a trees layer. You might create templates to represent the various types of trees one could add, like 'pine', 'maple', 'birch', and so on. Here's a link to a help topic. Manage feature templates—ArcGIS Online Help | Documentation 

Mike

RenRosin
New Contributor III

Hi Mike,

Thanks so much for getting back to me so soon. Yes, that's exactly what I was asking. Is there a way if changing the json code? ... I'm not a programmer, and I'm afraid of breaking something, but I wondered if I could do something like this:

0 Kudos
MikeMinami
Esri Notable Contributor

No, you can't do that as far as I know.

Mike

0 Kudos
RenRosin
New Contributor III

Thanks Mike.

0 Kudos