Select to view content in your preferred language

Filtering by Date in Autocomplete Search Questions

224
3
Jump to solution
07-21-2025 11:06 AM
GISAdminMLTMUA
New Contributor

Hello,

I am using Survey123 Connect 3.23 to build a survey with an autocomplete search function. The question pulls from the results of another Survey123 form through a REST endpoint. I have the autocomplete search question working properly, but I need to add a filter to the results to only show entries from the past 7 days.

I have a 'submitted date' field in the 1st Survey123 form that I am trying to use to filter. The way I have tried to filter the results is: submitted date > current date - 604800, after the main text in the 'appearance' field.

I have done a good amount of research and trial/error and I cannot come up with the correct syntax to get this question working properly.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
ChristopherCounsell
MVP Frequent Contributor
search(tableName, searchType, searchColumn, searchText, filterColumn, filterText)

The above is the expression you need to use for search()

You can use a SQL Where expression within the tableName parameter to filter the table. e.g. if submitted_date is your field:

"layerName?url=https://yourserver/FeatureServer/0&where=submitted_date > CURRENT_TIMESTAMP - INTERVAL '7' DAY"

You would need to update your other parameters but it would look like:

search("layerName?url=https://yourserver/FeatureServer/0&where=submitted_date > CURRENT_TIMESTAMP - INTERVAL '7' DAY", searchType, searchColumn, searchText, filterColumn, filterText)

https://community.esri.com/t5/arcgis-survey123-blog/dynamic-choice-lists-using-search-appearance/ba-...

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformsappearance.htm#ESRI_SECTION1_46A7...

 

View solution in original post

3 Replies
ChristopherCounsell
MVP Frequent Contributor
search(tableName, searchType, searchColumn, searchText, filterColumn, filterText)

The above is the expression you need to use for search()

You can use a SQL Where expression within the tableName parameter to filter the table. e.g. if submitted_date is your field:

"layerName?url=https://yourserver/FeatureServer/0&where=submitted_date > CURRENT_TIMESTAMP - INTERVAL '7' DAY"

You would need to update your other parameters but it would look like:

search("layerName?url=https://yourserver/FeatureServer/0&where=submitted_date > CURRENT_TIMESTAMP - INTERVAL '7' DAY", searchType, searchColumn, searchText, filterColumn, filterText)

https://community.esri.com/t5/arcgis-survey123-blog/dynamic-choice-lists-using-search-appearance/ba-...

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformsappearance.htm#ESRI_SECTION1_46A7...

 

Town_of_Fuquay-Varina_GIS
Occasional Contributor

<woops can't delete>

0 Kudos
CalvinHarmin
Frequent Contributor

I'm not sure if this is relevant, but AGOL stores dates as epoch milliseconds. I noticed your math is using 7 days in seconds, 604800. I wonder if you would need to add three zeroes to that, otherwise you are only subtracting 0.007 days?

0 Kudos