Dynamic Date Value in Filter Widget using ArcGIS Online

1539
13
Jump to solution
11-29-2017 11:43 AM
Highlighted
Occasional Contributor II

Hello,

We just updated our crime mapping application to be fed near real time and so now we are looking to have our update our Web App Builder to provide a better user experience.

We are wanting the field values in the filter widgets to be dynamic as the data changes so that it, on load shows the dates as being between the Current Date - 30 Days and the Current Date. I tried following the instructions that Jake Skinner‌ posted in his Document https://community.esri.com/docs/DOC-8191 and it worked for the Web Map but doesn't seem to work for the Value field of the filter in the attached image of the JSON code. We are only using ArcGIS Online and are looking to avoid putting the app hosted on our IIS because the whole reason we switched to ArcGIS Online was to take traffic away from our IIS.

Does anyone know if this is possible to do?

CC: MTwietmeyer-esristaff

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

Greg,

   Well that will not be possible with the AGOL version of WAB then.

View solution in original post

Reply
0 Kudos
13 Replies
Highlighted
MVP Esteemed Contributor

Greg,

   The filter widget offers a "in the last" option...

Highlighted
Occasional Contributor II

Hi rscheitlin

While this gets closer to what I am wanting, I want the users to be able to set a date range and then the default date range shows what is currently on the filter shown on the map.

We provide crime data for up to 1 year back and so I have built in an initial filter that is only showing crimes within the last 60 Days but I want them to on load see the date range as being 9/30/2017 - 11/29/2017 rather than just an arbitrary in the last 60 days

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

Greg,

   Well that will not be possible with the AGOL version of WAB then.

View solution in original post

Reply
0 Kudos
Highlighted
Esteemed Contributor

Were you ever able to get a solution to this problem?  If so, what did you end of doing?  This functionality would be useful to make an existing static application much more dynamic and helpful for endusers.

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Greg Mattis wrote:

 

We provide crime data for up to 1 year back and so I have built in an initial filter that is only showing crimes within the last 60 Days but I want them to on load see the date range as being 9/30/2017 - 11/29/2017 rather than just an arbitrary in the last 60 days

Hi Greg Mattis

I assume your data are all hosted on arcgis online, right?

If your data were stored in an enterprise database and shared in ArcGIS Enterprise (Server), I could've given a solution that I works for me.

Thanks.

Tanu

Reply
0 Kudos
Highlighted
Esteemed Contributor

Tanu:

Can you please provide details about your potential solution?

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hi Michael Volz‌,

Here is what you can do:

  1. Use ArcGIS Pro (1.4 or higher)
  2. Choose Add Data | Query Layer option from the Map ribbon (Create a query layer—Query layers | ArcGIS Desktop)
  3. Select a database connection
  4. Provide a name
  5. Enter a SQL like the below
    select * from EARTHQUAKES_7DAYS_LIVE  where ::r:TimeRange
    NB: the string after ::r: can be anything e.g. ::r:XYZ
  6. You will see a pencil icon next to ::r:TimeRange, click it

    • (a) enter the field name, that stores date/time values, in the Field or Expression box
    • (b) choose 'Date' from Data Type drop down box
    • (c) have Default Value box checked
    • (d) add an expression such as the below (the one used in the screenshot above uses an expression that is specific to SQL Server; check with the help for your flavor of database)
      DATEADD(DAY, -1,  CURRENT_TIMESTAMP)
    • (e) add an expression like this:
      CURRENT_TIMESTAMP
    • click Done
  7. Click Next > button
  8. Pick Unique Identifier Field(s), Geometry Type and Spatial Reference if not get chosen automatically
  9. Click Finish button
  10. Now you should see your layer showing 1 day worth (from now) of data
  11. You should see the Time Slider showing up as well but it should be disabled
  12. Enable the time slider and slide to any time window, you will see the map shows data from that specific time window
  13. Disable time slider and again you will see the most recent data (i.e. 1 day)
    if you open this map later in the future, you will always see the most recent data
  14. You can share that out as a map image layer (aka map service)
  15. Add the map service to a web map app such as ArcGIS Online/portal Map Viewer and use Time slider to see the same experience that you see in Pro.

Notes:

Hope you will find this helpful and let me know if you have any question.

Thanks.

Tanu

Reply
0 Kudos
Highlighted
Esteemed Contributor

Thanks.

I was wondering if you ever work with Oracle databases as the parameter link you provide is helpful but I still get a Underlying DBMS error [ORA-00936: missing expression] when I follow the instructions for the Default Value range

I think this would be going back 7 days from the Current date.

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Michael,

I tried the following and it worked for me.

In Oracle, when you add/subtract a number from a date/time, that number represents days.

Reply
0 Kudos