Select to view content in your preferred language

Automatically Filling a Year field from Date in a feature layer

364
2
07-03-2023 03:14 AM
Labels (2)
SeanDugan
New Contributor

Hi Everyone,

I have a legacy project which was started by my predecessor  . We have a Survey123 form for the public to submit records, and an associated dashboard to show these records to the public as they come in. This had been set up in such a way that in the feature layer there is a "Year" field which is not in the form, and does not get populated when the form is submitted. However, the web map that the dashboard uses displays points by "Year", so when a new record comes in that doesn't have "Year" completed it doesn't show up on the map, and I have to manually enter the Year. Not great if I'm off for the weekend!

Is there a way to set up an expression in the feature layer that would automatically populate the "Year" column from "Date"? Or would I be better to set up another web map where I display points by "Date" and just group the values to each year?

Any thoughts would  be appreciated!

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

You could set the symbology to Year($feature['your-date-field']).

Or if you keep using the legacy field, in the form, you can have that field calculate with format-date(${your-date-field}, '%Y').

- Josh Carlson
Kendall County GIS
BimallNaidoo1
New Contributor II
Hi

I am not if this will be helpful. We were collecting field data (using Survey 123) and had to have the date as part of the unique ID for the patrol. This is a very long winded way of doing this, unfortunately I don't do coding so there maybe an easier way.
I included date in the "type" field and selected hidden in the "appearance" field and made today() the "default". I then added another field with integer in the "type" field and used this formula format-date(${NewDate},'%Y') under "calculation". So it automatically populates when the record is submitted.
Hope this helps.
0 Kudos