Select to view content in your preferred language

Date Filter in Feature Layer in AGOL

164
3
Jump to solution
4 weeks ago
bofiel
by
New Contributor II

I have a feature layer for my roads that is hosted by SDE but also exists in an AGOL web map where the edits in Pro kick up directly to AGOL in real time. I wanted to create a copy of my Roads layer online and set a filter to "History date is within the last 5 years" but I saw here that the "In the Last" filter option for date is only available for hosted layers? Is there a workaround for feature layers that are not hosted to set up a similar filter?

0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor

You could probably do this by tweaking the underlying JSON of your webmap using ArcGIS Assistant.

What I'd suggest is add a hosted layer and apply the "in the last 5 years" filter to it. Now, log into ArcGIS Assistant, navigate to the Web Map, and inspect its JSON. The layer information will be in the Data grouping. Find the layer that uses that filter and then you should see an entry for DefintionExpression. That section of JSON will look something like this:

ago_definition_expression.jpg

Just copy the text of the definition expression, tweak it to apply to your layer of interest, and then paste it into that layer's definitionExpression property. Since you're directly editing your web map, I would highly suggest making a copy of the map and testing this out in the web map copy first. Make sure it works before you alter your actual web map.

View solution in original post

0 Kudos
3 Replies
SteveCole
Frequent Contributor

You could probably do this by tweaking the underlying JSON of your webmap using ArcGIS Assistant.

What I'd suggest is add a hosted layer and apply the "in the last 5 years" filter to it. Now, log into ArcGIS Assistant, navigate to the Web Map, and inspect its JSON. The layer information will be in the Data grouping. Find the layer that uses that filter and then you should see an entry for DefintionExpression. That section of JSON will look something like this:

ago_definition_expression.jpg

Just copy the text of the definition expression, tweak it to apply to your layer of interest, and then paste it into that layer's definitionExpression property. Since you're directly editing your web map, I would highly suggest making a copy of the map and testing this out in the web map copy first. Make sure it works before you alter your actual web map.

0 Kudos
bofiel
by
New Contributor II

That worked! Amazing workaround thank you so much!

bofiel
by
New Contributor II

Just as a follow-up, I also tried doing this to a Map Image view only layer in the JSON and it didn't work. Any recommendations on a similar operation for a Map Image layer?

0 Kudos