AnsweredAssumed Answered

Using a dynamic date for the Filter widget

Question asked by on May 29, 2017
Latest reply on Aug 1, 2018 by kmsagis


I have a WAB application which is used by a helpdesk team and it shows a layer that contains a lot of incidents.


At the moment I have 2 different layers for them in the webmap.

One layer contains all incidents regardless the type of information.

Another layer is already filtered through the MXD to show only last week's incidents.


Aside those two layers, I've added the filter widget to enable them to filter the complete layer (which is not shown by default at startup).


This situation of two similar layers causes a lot of confusion and not user friendly!

I want to enable them to have only ONE single layer which is filtered by default to show only TODAY's incidents.


Robert Scheitlin, GISP was extremely helpful to show me how to start the app with the filter enabled!


But when I have a datetime filter which asks for parameters.. it becomes impossible to initialize that filter on startup + I cannot find any way to have the filter's date value dynamic for today's date.


So for a dynamic date of today I can find a workaround.. a HORRIBLE one but it's better than nothing - Run a script every night to inject today's date in the configuration file on the filter widget.


But.. because I cannot initialize this filter on startup of the widget.. it does not help me show a filtered layer.. It takes an extra click from the user each  time the application starts and it's just not right.


I tried using the Enhanced Query widget but it does not know functions such as GETDATE().. I also tried do "convert(date,GETDATE())".

I found a great article to show how it's possible to filter a webmap layer dynamically with dates (by Jake Skinner -, which then GETDATE() do works! but that same technic does not work on the widget.


I also tried the enhanced search widget of Robert, but when running the SQL statement, my browser just freeze to death


This is so basic for a filter widget! I'm shocked to see it does not exists or so complicated to achieve! despite the fact it's an SQL statement!


Can anyone think of a better solution please?


Let me just emphesis that the layer cannot be filtered through the webmap or the MXD project, because the user should have the option to change the filter and investigate the rest of the records.







P.S. I just notice it might be a similar post to Toni Sevenius