Hi!I have published a feature service and a web map to ArcGIS Online that shows some point features. Every feature has a date attribute that I would like to use for filtering. The filter is easy to set for a certain date but is it possible to set the filters value for current date? So that the filters value would be dynamic.If this is not currently possible, it is a feature that should be implemented.Any way that I can get around this problem? The point is that I have a lot of data in one feature service but I would like to see only those that are dated for current date.
Any luck with this? I'm trying to do something similar with a feature service. I want to filter on current date. The feature service is editable and syncable so it can be used in Collector. As you noted you can't filter on current date in the web map layer properties. I've tried setting a definition query in ArcMap when I publish the service as James Crandall suggested. The service observes the definition query when it is published but it seems that it is ignored as the current date changes or any edits are made. Did you find a work around? Did a definition query in ArcMap work for you?
Post here just in case anyone who may need it:
Try ArcGIS Online Assistant
You can see the JSON data of your web map, and you can change the layer definition and save back.
In the layer definition, define your own expression and save.
"layerDefinition": {
.....
"definitionExpression": "CreationDate >=DATEADD(day,-1,convert(date,GETDATE()))"
......
}
USING THIS TOOL AT YOUR OWN RISK, AS IT COULD CORRUPT YOUR CONTENT. so I strongly suggest make a copy before you change anything.
Hi Simo,
I'm not familiar with JSON. Where exactly do you put this Definition Expression? Could you provide an example?
Where would I insert that expression in the following JSON:
{
"layers": [ { "0": { "id": 0, "layerDefinition": {
"drawingInfo": { "renderer": { "type": "simple", "label": "", "description": "", "symbol": { "angle": 0, "xoffset": 0, "yoffset": 12, "type": "esriPMS", "url": "737ec596-f3ab-4-b8f4-9c952cc048d6", "imageData": "iVBORw0KGgoAAAANSUhEUgAAACYAAAAzCAYAAAD7JnqGAAAetc", "contentType": "image/png", "width": 27.999999999999996, "height": 38 } } } } },
Also, to take this idea of using arcgis online assistant one step further is there a way to query a date range to get a similar result?
Thanks for the help.
Hi Andre,
something like the following will do the trick.
JSON is javascript, and the value for layerDefinition is a Javascript object.
To answer your last question, I am pretty sure you can query a date range. all you need to do is find out the MS SQL Server syntax for it. Something like "Date >= '2015/12/01' and Date <= '2015/12/08'" should work
"layers": [
"0": {
"id": 0,
"drawingInfo": {
"renderer": {
},
Has anyone found a better way of doing this yet?
I tried the editing the JSON in ArcGIS Online Assistant using the script that simo xu however this was not successful.
I've just found this!!
You can filter dates using In the last.
Note: this is only available for Hosted Feature Layers (Apply filters—ArcGIS Online Help | Documentation )
I found this link but I need it in the Portal.
Dynamic Date Filter
You must sign in https://www.geo-jobe.com/admin-tools/ and it's 1000$ / year.
it is too expensive for us.
If anyone has another solution to modify the Data in Json in Portal ...
Or an other solution.
I've never done it myself.
You can use this filter and put "not in the last" 1,000 days, and it is almost the same as "on or after" today.
This is exactly that I was looking for, thank you Naomi!
This works for me. However in a popup from another layer showing related records for the filtered table doesn't work: it just loads non stop.But if i change the filter to "date is after today" (selecting today's date), then it works without problem. I just need to be able to put today dynamically with today() or something.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.