Dynamic Choice Lists using Search Appearance

46100
69
05-23-2021 09:45 PM
BrettStokes
Esri Contributor
14 69 46.1K

Background

The use of dynamic (constantly changing) choice lists in Survey123 has become a popular feature for survey authors since the introduction of linked content CSV files. This method uses the data contained in a CSV file hosted in an ArcGIS organisation as the choice list values in your surveys. This allows the choice list values to be managed outside of Survey123 by updating the linked CSV file if necessary when the survey is opened, and ensures the latest choice list values available to your survey users.

An additional method for incorporating dynamic choice lists into your surveys is supported in the 3.13 release of the field app and web app. This blog will take a deeper look into this new search() appearance and provide more details on what is possible and how to set it up.

This new method is configured by adding a search() expression to the appearance column of a select_one or select_multiple question in your XLSForm. The search() expression can reference a hosted CSV file, or a feature layer or table in ArcGIS through its REST URI. Referencing a layer that has geometry gives the additional capability to utilise spatial queries to populate the choice list. Some example use cases for spatial queries include populating a choice list dynamically with:

  • incident report ID values from features within a search polygon (defined in the survey itself).
  • asset ID values within a specified distance on your current location.

 

Getting Started

If you’re new to using choice lists in Survey123, please check out the blog titled Survey123 Tricks of the Trade: Choice Filters as a starting point.

To get up and running with the search() appearance we should first set up a survey with a select_one or select_multiple question. You must still include an entry on the choices worksheet but instead of listing each of the choices, you will reference the field name from the existing feature layer or table.

In the following screenshot a choice list called ‘us_states’ is defined on the choices worksheet and will use the field ‘STATE_NAME’ for both the choice name and label.

BrettStokes_0-1631753728945.png

The search() appearance can be used alongside other appearances, and should be used with the ‘minimal’ or ‘autocomplete’ appearance (best practice for all very large choice lists). This prevents the form from trying to render all available choices, causing performance issues.

 

Understanding the Search Expression

Let’s take a look at the syntax used when building a search expression:

search(‘tableName’, ‘searchType’, ‘searchColumn’, ‘searchText’, ‘filterColumn’, ‘filterText’)

tableName

The ‘tableName’ parameter is the only required parameter, it specifies which table is going to be queried. This parameter has a different format depending on whether you’re referencing a local CSV (just use the CSV filename, without the file extension):

  • search(‘usa_states’)

or an ArcGIS layer (use the format ‘<unique_name>?url=<Layer REST URL>’, including the layer index). The <unique_name> can be anything, it doesn't need to match the name of the hosted layer, but as this is how Survey123 internally refers to your search, must be different from all other table names and CSVs used in the survey:

BrettStokes_1-1631753728954.png

Since both of these search expressions don’t use any other query parameters, the entire contents of the table will be used to populate the choice list.

Tip: You can optionally append query request parameters to the REST endpoint of your feature layer or map service layers to configure the search behaviour. This can be really useful for incorporating buffers of query geometry using &distance= and &units=, as well as limiting the number of query results using &resultRecordCount=. These URL parameters can also be set by the user in the form itself, see the Point intersects buffered points (with attribute filter) example below for details.

 

Optional Parameters

There are tables in the documentation that describe each of the optional parameters that can be used to narrow down the query results:

BrettStokes_2-1631753728963.png

Let’s use these reference tables to help us understand two search expressions that utilise spatial queries (both are included in the ‘Dynamic Choice Lists using Search Appearance’ sample survey available in Survey123 Connect).

 

Polygon contains points

This example populates a choice list by returning values (in this case public school names, but can be any attribute value) from point features that are contained in the search polygon digitised by the survey user. It uses a geoshape question to allow users to define the search polygon and then a select_one question for users to select from the dynamic choice list.

BrettStokes_3-1631753728967.png

 

BrettStokes_4-1631753728968.png

 

BrettStokes_5-1631753728969.png

Here is the search expression in full:

search('school?url=https://services1.arcgis.com/Ua5sjt3LWTPigjyD/arcgis/rest/services/Public_School_Location_201819/FeatureServer/0', 'contains', '@geoshape', ${search_poly})

tableName:

  • unique name school for Survey123 internal reference (could be any unique string):

BrettStokes_6-1631753728969.png

  • REST endpoint URL including the layer index (0):

BrettStokes_7-1631753728970.png

searchType:

  • using the spatial relationship ‘contains’, to return features in the layer that are completely contained by query geometry. Any appropriate spatial relationship could be used:

BrettStokes_8-1631753728971.png

searchColumn:

  • using ‘@geoshape’ for this spatial query, as this is the query geometry type (ie polygon / geoshape):

BrettStokes_9-1631753728972.png

searchText:

  • for spatial queries, this references the survey question that will provide the query geometry. Notice that parameter values don’t need inverted commas when they reference a previous survey question, ${search_poly} in this case:

BrettStokes_10-1631753728973.png

 

Point intersects buffered points (with attribute filter)

There are two examples in this group. The first example is supported in both the web and field apps as the search geometry (a 0.5 mile buffer) is hardcoded into the search expression. We will look at the second example here as this extends upon the first example to allow the survey user to define the buffer parameters on the fly (currently not supported in the web app). Both examples use all of the optional search expression parameters.

The use case for this example is a scenario where a choice list (in this case Store names) is populated dynamically based on your location and the search distance you specify. You can optionally apply a filter based on the Store category to further refine the choice list.

It uses a geopoint question to define your location, which is intersected with the buffered Store locations based on search distance (range question) and search distance unit (select_one question). Additional select_one questions provide the optional Store category filter and the final Store selection to make use of the resultant dynamic choice list.

BrettStokes_11-1631753728989.png

BrettStokes_12-1631753728991.png

BrettStokes_13-1631753728994.png

Here the search expression is built in 2 steps.

Step 1 - creates the tableName parameter by adding the buffer parameters to the feature layer URL using the ‘concat’ function (in the calculate question named ‘search_url’). The calculation in full is:

concat("store?url=https://services6.arcgis.com/Do88DoK2xjTUCXd1/ArcGIS/rest/services/OSM_Shops_NA/FeatureServer/0&units=",${search_distance_unit},"&distance=",${search_distance})

tableName:

  • unique name store for Survey123 internal:

BrettStokes_14-1631753728996.png

  • REST endpoint URL including the layer index (0):

BrettStokes_15-1631753728999.png

  • the optional query request parameters (‘units’ and ‘distance’) are appended to the REST URL of our feature layer (see documentation for feature service layers or map service layers for the full list of request parameters). These values can be hardcoded, but this example takes them from previous survey questions, namely ${search_distance} and ${search_distance_unit}.

BrettStokes_16-1631753729001.png

The ‘search_distance’ question is displayed as a slider (ie a ‘range’ question type), while the ‘search_distance_unit’ question provides the options across the screen (ie a ‘select_one’ question with the ‘horizontal’ appearance).

Step 2 - adds the optional search parameters to complete the expression, here it is in full:

search(${search_url}, 'intersects', '@geopoint', ${search_point2}, 'shop', ${store_cat2})

searchType:

  • using the spatial relationship ‘intersects’, to return features in the layer where the buffer intersects the query geometry. Any appropriate spatial relationship could be used:

BrettStokes_17-1631753729002.png

searchColumn:

  • using ‘@geopoint’ for this spatial query as this is the query geometry type (ie the location point):

BrettStokes_18-1631753729003.png

searchText:

  • the survey question that will provide the query geometry. Once again, notice that that parameter values don’t need inverted commas when they reference a previous survey question, ${search_point2} in this case:

BrettStokes_19-1631753729005.png

filterColumn:

  • the field from the feature layer for which we can apply an additional attribute filter. This will obviously depend on the feature layer itself, in this example we’re using the ‘shop’ field (this contains the store categories).

BrettStokes_20-1631753729006.png

filterText:

  • this text value can be hardcoded into the expression but is far more useful if it refers to a previous survey question. This way the survey user has control over applying the filter. Since we’re filtering on store categories in this example, these options are supplied in a static choice list named ‘us_stores_cat’ which is used by the select_one question ${store_cat2} in this case:

BrettStokes_21-1631753729007.png

 

The explanations for these example search expressions should improve your understanding of dynamic choice lists in Survey123. You can use the ‘Dynamic Choice Lists using Search Appearance’ sample available in Survey123 Connect to view how these examples work and edit them to fit your needs.

Tags (1)
69 Comments
RosemaryHatch
Regular Contributor

Hi! Very excited about the search() feature, however is there a trick to recognizing which hosted layers can be used? I'm trying to pull in a list of addresses from one of our layers and don't seem to get any results. I can replicate all of the examples you've listed above, and have no problem using the example feature services, but I must be missing something.

worksheet snip.PNG

worksheet snip 2.PNG

LiamHarrington-Missin
Frequent Contributor

Thanks @BrettStokes,

Been getting my head around this, this morning.  A powerful feature with some great applications. 

It should also be noted that this works with the rank question type (UPDATE: If you set the "parameters" field to "randomize=true" it breaks the rank question if you are using dynamic choice list).  UPDATE Again: Whilst Survey123 Connect shows the expected behaviour of a dynamically linked Rank question, when you publish and view it, it fails.  Therefore, you can't currently use dynamic lists for a rank question.  Would be nice to add though.

Question though, I assume this only works online.  There is no way to download an offline version of the list for offline workflows and update when back in cell range. 

Cheers for the good work.

I think quite a few questions in the forum need directing to this post since it appends nicely to anything along the lines of "external choices" or "external data".  It took me quite a while to find this post even though I remember reading it.

MichaelBruening
Frequent Contributor

@LiamHarrington-Missin if you have access to ArcGIS Pro, then you could perhaps do the following. If you have a Hosted Feature Service that you are building choices with based on another work flow and want to use it within a Survey123 form, then you could create a model builder in Pro that will download the Hosted Feature Service as a table, delete unneeded data fields, load the choices into a predetermined table schema that matches the CSV file formats; for "linked content" - https://community.esri.com/t5/arcgis-survey123-questions/can-a-linked-csv-file-on-agol-be-automatica... and then have a script that will upload AND REPLACE the existing csv file that is part of the linked content for the survey form.

If you are not part of the Early Adopter Program, then I would highly recommend creating an account and looking at this article. https://earlyadopter.esri.com/project/article/item.html?cap=e69ef91f45744b98882c651f7b518eb7&arttype...

I had created a model builder last summer that would take the responses from one survey, download them, create a new csv table, and then it would upload and replace a "linked csv" file that contained the choices for a question within a different survey. The beauty of this setup is the the Survey Form now automatically checks EACH time it is opened while CONNECTED to the internet for updates. If there have been any updates to the Survey form or linked content, then Survey123 should prompt the user for an update.

I do know that within the export script you would need to use some panda programming language to drop the "ObjectID" field and convert and export the table as a csv file; unless there has been an update to PRO the allows a direct csv export without the OID.

I used this code below within a Python Script that was used within the model builder I had created. You will also need another script that will log you into your ArcGIS Online account, that references the "ID" of the csv file, and location it is stored to upload and overwrite the csv file (See second script).

Export table without OID

import arcpy
import pandas as pd

arcpy.env.overwriteOutput = True

# Read CSV into pandas DataFrame
df = pd.read_csv(r"MyFilePath\MyFileName.csv")

# Drop OID column
df.drop('OID_', axis=1, inplace=True)

# Write DataFrame to the same CSV as the input
df.to_csv(r"MyFilePath\MyFileNameFinal.csv", index=False)

 

Upload csv file and overwrite existing within ArcGIS Online. (this will use the Username and password of the person logged into the ArcGIS Pro account that you have the scheduled task/model builder running within. So, no need to hardcode in your username and password. 😉

#!/usr/bin/env python
# coding: utf-8

# In[1]:


import os, sys, arcpy
from arcgis.gis import GIS

source = GIS("pro")
csv = source.content.get('UniqueID of ArcGIS Online Linked CSV file')
csv.update({}, r'MyFilePath\MyFileNameFinal.csv')
csv.publish(overwrite=True)

This is what the model builder looks like below. The "CleintInfo_ProjNmbrs_Drop_OID_From_CSV_Direct_SC" would be the "Export table without OID" script from above and the "ClientInfo_Media_Folder_Update_CSV" would then be the "Upload csv file and overwrite existing within ArcGIS Online" script from above. I would build this in order from the top downward. So, delete the existing csv file from your local, download the new table and append into a master setup table, sort if you want to, then complete a table to table, create a copy that will be used in the delete OID, then upload and replace.

MichaelBruening_0-1633004385695.png

It appears as though we can no longer upload attachments within this site. I would upload an attachment that contains a Word Document and two scripts that would walk you through the process. If you are interested, then I think you should be able to direct message me through this site.

 

UPDATE (7/25/2023) - If anyone is using my method for the replacement of the csv file, then you will notice that you might be receiving an error after upgrading to the latest version of ArcGIS Pro V3.1. This is due to ESRI dropping the "table to table" tool; they also dropped "Feature Class to Feature Class", from ArcCatalog. I have not updated to the most recent version due to the dropping of these tools. I have been trying to explore the online documentation to see which tool can be used within its place that replicates the tool.

 

UPDATE (11/20/2023) - The "Export Data" tool that was introduced within ArcGIS Pro is supposed to take the place of the "Table to Table" and "Feature to Feature" tools. I have yet to test the new tool, because I am still using v3.2.0 until our 2023 field season is over with to ensure no hiccups. I will do some testing after the season ends and post an update for those of you who are using this method.

Oretana_
Occasional Contributor

Hi! 

I'm ussing dynamic choice list to enhance a form with the aim for the client to be able to update the list of options for a multiple choice question.

It works correctly but the apparence in the question is of default minimal type and I would like to see all options directly.

Oretana__0-1634634397739.png

Oretana__1-1634634701068.png

I would like it to be like this:

Oretana__2-1634634892646.png

I don't know if there's shomething I'm not taking into account. 

Thanks for your help in advance.

 

 

 

SharonAshkenazi
New Contributor

Is it possible to search in previous repeated question answers?

SarahWright1
Frequent Explorer

@RosemaryHatch did you ever resolve your issue where search() doesn't return any results? I am running into the same problem where it seems to work fine with certain layers but others result in a blank dropdown.

RosemaryHatch
Regular Contributor

@SarahWright1  Not sure if this is the same issue for you, but this was our workflow and the work around if it helps anyone else:

My survey was created in ArcGIS Online (to get around the associated pictures issue with Enterprise) but I was trying to pull in a public layer hosted in our Portal.

Apparently, public layers hosted with enterprise (instead of ArcGIS Online) can't be used with an ArcGIS Online survey unless they are PRIVATE and then you pull them into your arcgis online and save the credentials. It's a strange limitation, but the only solution we found after many support calls. Hopefully your issue is less convoluted 🙂 

 

MirandaWilson
New Explorer

This is really exciting functionality but is it available  for offline use?

Skyler
by
Occasional Contributor

@MirandaWilsonNo, it is not available for offline use. I posted here in ArcGIS Survey123 Ideas about adding offline functionality.

MichaelBruening suggests a alternate workflow in his post above.

VincentMcClarty
Frequent Explorer

Hi,

When I use the sample Dynamic Choice Lists using Search Appearance it works correctly in ArcGIS Survey123 Connect when signed in to ArcGIS Online, however when I'm signed into an ArcGIS Enterprise 10.8.1 Portal it doesn't populate any of the lists.

Any idea why this is the case?

Thanks

Vince

Bryan_Chandler
Occasional Contributor

Hi,

I am building a Survey and I am using the Dynamic Choice List option in Survey123 Connect.  The Survey is pulling the choices but I seem to be missing any past the 2000th table entry.  Is there a limit to the number of records that can be used to populate the choice list?  My reference Hosted Table in ArcGIS Online has 3200+ entries and will grow over time.  

Thanks for any info on this,

Bryan

Bryan_Chandler
Occasional Contributor

I was able to determine that the solution to my problem was to increase the Max Record Count in the Hosted Table in ArcGIS Online.  Used the Update the maximum record count for feature services in ArcGIS Online to update the REST endpoint and the Survey now pulls the full table for the Dynamic Choice List!  

KyleHeulitt2
Occasional Contributor

How does one use the Search appearance to search or filter a feature layer using a date field?  I can't seem to get it to work.  I'm specifically interested in filtering on blank/NULL date records, but I can't seem to get it to work even when I enter a specific date.  I've tried various ways, including epoch time, to no avail.  If anyone can post an example of the proper syntax it would be most helpful.

Thanks!

Kyle

KristinThorpe1
Regular Contributor

I'm having a problem with using search() inside a repeat. I am using my survey to conduct field inspections at construction sites. I have several select_one questions with search appearance to generate dynamic lists to determine which construction site to inspect. However, when the search() is inside a repeat, the selected site does not save when I add a new repeat. If I add a second repeat and go back to the first, the select_one questions are empty. Any incite as to why this would happen?

KimberlyMcCallum
Regular Contributor

@KristinThorpe1 Hi! I am having a similar problem. I have a search() to pull choices from a feature service table. It includes parameters to filter the choices by matching another field in my survey (not in the repeat). Everything seems to work (filtered choices are returned) as expected for the first record in the repeat but in the subsequent records, the filter parameters are ignored.

Have you been able to resolve your issue? Do you have any ideas to share? 

HelenZhou
Frequent Contributor

Hi@BrettStokes, this blog is very useful. Thanks.

I have tried to use feature/map service published from our GIS server. It doesn't seem to work for  Survey 123 Connect. Here is what I have defined- 

The excel "survey" tab - "autocomplete search('MyAddress?url=https://testgis2.arlingtontx.gov/agsexttest2/rest/services/Query/MapServer/23')"

The excel choices tab - list_name "ValidAddressList", name: "Address", lablel "Address"

What is wrong? I have tried to use another feature service published from the same GIS server for test, it still doesn't work. When I try to use the url in your blog or another ArcGIS online feature service. It works. Does the service have to be hosted in the ArcGIS online?Survey123UrlDropdown.png

JavierCMartínezPrieto
Frequent Contributor

good morning @HelenZhou ,

I don't know if it will help you, but the same thing happened to me, the search() function didn't recognize the name of the table (in my case) where I had to look for the value.

My solution was that I had misspelled in choice the name of the column where I had to look for the value, that is to say the name that you put in choice has to coincide with the name of the column or file where the search() function has to look for, in your case:
The excel choices tab - list_name "ValidAddressList", name: "Address", lablel "Address", list name and name has to have the same name as the location where the value is searched.

I hope this is helpful

 

########################ESPAÑOL############################################

buenos días @HelenZhou,

no se si te servirá, pero a mi me pasaba lo mismo, la función search() no me reconocía el nombre de la tabla(en mi caso) donde la tenia que buscar el valor.

mi solución fue que tenia mal escrito en choice el nombre de la columna que donde tenia que buscar el valor. es decir el nombre que pones en choice tiene que coincidir con el nombre de la columna o archivo donde tiene que buscar la funcion search(), en tu caso:
The excel choices tab - list_name "ValidAddressList", name: "Address", lablel "Address", list name y name tiene que tener el mismo nombre que la ubicación donde se busca el valor.

espero que te sea de ayuda

saludos

greetings

 

JaquelineEdwards
New Explorer

Has anyone experienced issues with this working properly in the web version of Survey123 but not working in the app, despite it being compatible based on the instructions above? I'm not working offline if it helps. 

Jay_Gregory
Frequent Contributor

@Bryan_Chandler et all - 

You solution for updating the max record count of your feature service might work if you only have a small number of records, but what if I am trying to query a feature service with 500k records?  A query returning 500k features would take too long.  Ultimately, the design of this feature seems to operate as so:

When you load the form, a single query to the feature service retrieves however many records it can and populates the select_one from that list.  

Seemingly, how it should work, is when you are typing into the select_one text box, it should perform a dynamic query (where=fieldname LIKE '%{inputtext}%') to retrieve a smaller list of results, similar to how the search widget in the JavaScript works.  After the 3rd character, the search widget just starts querying the REST endpoint after each character, resulting in an ever-narrowing down list of results that match your text input.  

Does anyone have any ideas on how to get this to work for much larger number of records?

CVHCMaster
New Contributor

Hi @Jay_Gregory,

Have you watched  ArcGIS Survey123: Advanced Smart Form Design from the July 2021 User Conference?  Go to the 9:42 & 11:15 timestamps, where Brett Stokes reviews adding autocomplete in the appearance field (in addition to the search() function).  The Dynamic Choice Lists Using Search Appearance Sample from Survey123 Connect is the xlsx smart form he reviews in detail.

Are you also able to filter your list of 500k records by asking a question in your survey to narrow down options found using the search() function?  Examples @ 11:15 & 12:30 & 13:00 timestamps.

Chris

 

rachelpapers
Occasional Contributor

@Skyler I haven't tried using this yet as all my surveys need to work where there's unreliable data connection; would you mind please just confirming that when you mentioned that this can't be used offline you just meant accessing dynamic lists? 

I really hope it doesn't also apply to the spatial search as I can think of lots of situations where that would be really useful for a user in the field.  Even if they could only recall their own records that'd be better than nothing.  I agree with your post that it would be ideal if it could also be forced to look for new records and update them to an offline cache in the background whenever someone is in a signal even if they aren't using the survey.

Skyler
by
Occasional Contributor

@rachelpapers: Yes, I was referring to accessing dynamic lists. I haven't tried using the spatial search functionality, so I can't speak to that. I'd suggest putting your device in airplane mode and testing it out.

chargeetudeti
Emerging Contributor

Hi

I have a problem with the search function. When used with URL, the filterText parameter only works
with a fixed element if i put a variable it doesn't work Does somebody have an idea
Don't WORK
autocomplete search('Code_Essai?url=https://services6.arcgis.com/xNifwnpI45tLCPU7/arcgis/rest/services/service_6c471d554de1493a8f7ec28b9...',${Identifiant_Compte})
WORK
autocomplete search('Code_Essai?url=https://services6.arcgis.com/xNifwnpI45tLCPU7/arcgis/rest/services/service_6c471d554de1493a8f7ec28b9...',"subdrayti")
Thank you
Julien

MichaelChristensen31
Occasional Contributor

This is great functionality, and very helpful to be able to refer to "live" lists and not needing to maintain lists separately in the surveys. I have attempted to add additional query parameters to the url string due to the need for searching with more than two parameters (search and filter). I cannot get this to work. I assume this may be by design. Some desired future functionality would be the capability to add more than two search parameters. If there is a way to do this that someone has figured out, I would very much appreciate some input.

anonymous55
Frequent Contributor

Hello

I have search function which I set to bind::esri:fieldType null and doesn't store any data on hosted layer.
Can I change null to String type without effecting hosted layer without deleting data and store new information on new field? 

RViruet
Occasional Contributor

@anonymous55Yes, you can!

First create the field in your service, making sure the name and datatype match the ones in your form. After the field is created, you can remove the 'null' value from the bind::esri:fieldType column for the record you desire. (Default type for calculations is string)

When you attempt to publish, you shouldn't get a warning 🙂

Hangglide
Occasional Explorer

Is there a way to have this display a list of labels but actually store an ID value? I need to save an ID number, but a user couldn't tell which one to pick, even with a lot of filters applied. Ideally, I would like to create a complex list to pick from but only store an ID. For example:
Select one (dynamic list searched and filtered from another feature layer):
2022 - Q1 - 2500 - Trout - Lower Saluda River
2022 - Q1 - 3500 - Trout - Upper Saluda River
2022 - Q2 - 2500 - Trout - Lower Saluda River
...
Save only the RequestID value associated with the selected record.
If this is not possible to do with this appearance search method, is there a way to pull a dynamic list from a JavaScript that would work?

If this is not possible to do with this appearence search method, is there a way to pull a dynamic list from a javascript that would work?

 

Edit:  This has been mostly solved by simply editing the Name and Label on the choices tab.  We are still looking for a solution to apply more than two filters.  

 

KevinG
by
Emerging Contributor

I’m having a problem using the select_one question with search appearance on a local csv. I need the select_one dropdown to be limited to choices from the csv where the value in the searchcolumn equals a value from a previous question (let’s use 2151 for example). It should be pretty straightforward, but the select one dropdown keeps returning blank when using the ‘matches’ searchtype. If I use ‘beginswith’ instead, I get choices show up in my select_one dropdown but they also include values from my searchcolumn such as 21512. 

In previous versions of Survey123, I had this working using a choice filter but that now returns no matches as well (not sure in which version that stopped working).

RosemaryHatch
Regular Contributor

@KyleHeulitt2 Were you ever able to get any documentation on how to use this with a date filter? I'd love to be able to filter on something like "after today". Thanks!

KyleHeulitt2
Occasional Contributor

@RosemaryHatch - No, unfortunately I never found a way to do this.

YukoYokozawa
Frequent Contributor

Is there a list of units? I want to use yards, but esriSRUnit_Yard doesn't work.

SMDSAdministrador
Occasional Contributor

Any ideas on how to filter an empty/null field? I've tried the expression below (and a few other variations), however, it just ignores the parameter and returns all the layer's records (not the ones where "agendado" is null).

search('calendario?url=https://services1.arcgis.com/OlP4dGNtIcnD3RYf/arcgis/rest/services/testeth_calendario_join_agendamen...', 'matches', 'agendado', '')

KarenClark1
New Contributor

I love this feature!!! I've been able to populate my select one with my dynamic list (Select a permit). Now I need to pull other attributes (Company, Address, Etc.) based on the choice from the dynamic list. I have successfully populated another select one type for pulling the Company with a single choice based on the answer from the Select a Permit list. However, the single available option has to be selected in order to save the Company as an answer. Is there a way auto select a single choice or to use calculate or another field type to auto fill other attributes from the dynamic list feature once a selection is made on a dynamic list? 

Jesan90
Occasional Contributor

Hi @BrettStokes ,

when using the search appearance, the options are loaded in alphabetical order, how do I make the options appear in a defined order.
I have tried to add the orderByField parameter "...FeatureServer/3&orderByFields=Orden DESC" but it doesn't work, I appreciate all the help given.

Notes:

  • orderByFields is true in supportsAdvancedQueries layer section.
  • I am viewing the survey on the web. On mobile if it works

 

Thanks,

Jeffry Jiménez

Sharouff
Occasional Contributor

I am also looking for a way to sort my resulting dynamic choice list in descending order?

PeterMacKenzie2
Frequent Contributor

Can the dynamic ArcGIS Layer be the forms own feature service? i.e. can it search "itself" to populate a list?
Example:

1. user enters a code of DUCK01 >  then submits.
2. user beings a new form
3. user opens dropdown list , would like to  see the recently added DUCK01 entry as an option

I just tried this and it looks in like it's stuck at the Converting XLS Form step when publishing, so does this mean it's not do-able? 

 

EDIT: this is possible and works like a charm. ✔️ (there must have been some other quirk converting the form). 

TonyGroeneveld3
Occasional Contributor

This works great and is exactly what I need however came across this glitch.

I have a field on the survey where the parent asset id is entered. I then use the above technique to populate a select one list of children assets for that parent.

The search works perfect when a parent asset id is entered by a user.

However I want to open the survey and prepopulated the parent asset id from a web map.

arcgis-survey123://?itemID=xxx&field:parent_asset_id=R-11223344

The survey opens, the parent asset id is filled in but my select one list has all records instead of just the children of the parent. It is like the search is executed but it doesn't know there was a value entered in the parent asset id.

I've tried a bunch of work arounds but have not come up with a solution. Wonder if anybody has found a solution to this. 

GregKeith
Frequent Contributor

Kind of late @Oretana_ , but if those are all your choices you're better off just putting them in the Choices worksheet.

CCGIS
by
Occasional Contributor

Thank you @BrettStokes this blog post has been super useful. In my case, I am trying to search within the same service. I have 3 survey questions, for example, ID, Name, and address all located in the same service. I am able to bring the ID column with no problem, but I am having trouble bringing the other 2 using the matches option. If the user selects an ID, I want to bring the Name and Address. I have checked for my names to be the same as the ones in the layer but I am not able to do it. Is this possible to search within the same service? Thank you.

This is for the ID: autocomplete search("Table?url=https://LongURLNameHere/FeatureServer/0")

This is for the Name: autocomplete search('NameTable?url=LongURLNameHere/FeatureServer/0','matches','Name',${ID})

 

Jesan90
Occasional Contributor

Hi @CCGIS ,

Yes, it is possible, and the way you describe it is correct. In my case, I apply the same logic of a cascading list, although I use it on a different service than the survey. However, there shouldn't be any difference. Try changing the parameter ${ID} directly to the text you want to filter, for example 'your-ID', to test that you have the correct syntax.

 

Jeffry J.

MattLayman
Occasional Contributor

@KarenClark1 I think I figured out what you're trying to do- I also had the same or similar problem. Based on which pipeline segment a user chose, I wanted to then fill out other attributes in the survey based on their answer to that first question (which was populated using attributes from a feature layer using the "autocomplete search" function in the appearance column of the survey's excel form). In the next question, I wanted to auto-populate an answer based on the answer to the first question, so I used the "pulldata" function in the "calculation" column- the syntax looks something like this:

pulldata("@layer", "getValue", "attributes.AttributeYouWantToPull", "yourFeatureServerURL/FeatureServer/0", concat("pipelineNameAttribute = '", ${previousQuestionFieldName}, "'"))

The "Query a Feature Layer" example in the Survey123 samples was helpful for me to get the syntax down and get ideas for other ways to automatically pull in data.Screenshot 2023-04-18 090300.png

Hope that helps!

VaneiriPatt
Emerging Contributor

Hello,

I have a database view that I published as referenced registered data. The output of this is a Feature Layer and Map Image Layer. The Feature Layer give me a Data Error but the Map Image Layer when added to a web map would show me the records.  I have tried pointing my search to the map image layer and no results is received. 

@RosemaryHatch were you able to get options on your end? I see you had a map server too.

SO.png

HelenZhou
Frequent Contributor

@VaneiriPattHave you tried to add the map service to your AGO account and then reference the AGO item ID in you Survey 123 Connect Excel spreadsheet?

 

VaneiriPatt
Emerging Contributor

@HelenZhou I am publishing to my ArcGIS Portal (Enterprise). I added the service to a map and had my survey use the web map url and still the options are now showing up on my survey. 

HelenZhou
Frequent Contributor

@VaneiriPatt I have found out Survey 123 reference url has to be either hosted in AGO/Portal or add a service (map/geocoding) to AGO/Protal and reference the item ID. Only Survey 123 app works with map service url published from a standalone ArcGIS server.

RobertAnderson3
MVP Regular Contributor

I for the life of me cannot get the search() appearance working on a CSV..

typenamelabelhintguidance_hintappearance
select_one assetIDsassetIDAsset ID:  w2 autocomplete search('ParkPointAppurtenances')

 

list_namenamelabel
assetIDsUNITIDUNITID

 

File name is: ParkPointAppurtenances.csv
Field name is: UNITID

The choice list is empty when I run it, I could get the feature layer search() to work but it only returned 2000 records and because of the way the layer is updated changing the maxRecordCount won't persist so I export it to a CSV instead.

Thank you for any help to catch what super obvious thing I'm missing!

EDIT: Okay I just feel silly, I had been using Python to create a CSV from a feature layer in AGOL and the tocsv command on the dataframe created an index field with a blank column header, so when I removed that my search() works fine.

AllardTerence
Emerging Contributor

 @KristinThorpe1and @KimberlyMcCallum were either of you able to find a solution to the problem of ‘searchColumn’, ‘searchText’, ‘filterColumn’, ‘filterText’ paramaters being ignored for dynamic lists within repeats?

 

@BrettStokes is this a known issue with the search() function, or are there ways to use the same search/filter parameters across a set of repeats? Currently I get the correct choice list for the first repeat, but for each of the following repeats the full un-filtered table of choices is returned.

Thank You,

-Terence

KristinThorpe1
Regular Contributor

@AllardTerence Mine was less of an issue with filtering the choice list with ‘searchColumn’, ‘searchText’, ‘filterColumn’, and ‘filterText’ parameters, but with maintaining the choice selection when navigating between repeats. If I remember correctly, I moved the search() outside the repeat and created fields inside the repeat to hold the value I selected. When a selection is made from the choice list, the field inside the repeat would calculate to that value. I also added a Yes/No question for the user to verify the selection is correct. A Yes answer will trigger the calculation.

anonymous55
Frequent Contributor

Hello 

I have autocomplete search function which return values within 1000 feet intersects and you can choose values from drop down. However, I am looking a way when user place point on map(geopoint question) and is not intersects with buffer of 1000 feet users getting message to show them their point isn't within desire buffer and because that drop down doesn't return anything

Thanks

abureaux
MVP Frequent Contributor

Will support for search( ) be added to Enterprise in the near future? 

Unless I am missing something, this doesn't appear to work in Enterprise. As soon as I try a test in AGO it works.