create select_one items from feature service and return multiple attributes

344
3
Jump to solution
02-28-2024 08:32 AM
MichaelKohler
Occasional Contributor II

I'm trying to populate a select_multiple field list from a feature service

I have a feature service of polygons with a "siteid" field. User clicks on map and the location is used to spatially query the feature service and return the "siteid" for the polygon. No problem with a script.

From this siteid, I want to select all assets that are associated with the siteid from a hosted feature table and return a description of the asset. Then, when an asset description is selected, I need to return the asset id for that asset and store in hidden field.

 I've put the data in a csv file in the survey123 linked content and tried the below and nothing is returned.

autocomplete search('PropSched','matches','site','${siteid})

 

I've also tried to do the search using the hosted table like below and nothing is returned.

 autocomplete search('prop?url=https://services1.arcgis.com/********/arcgis/rest/services/Property_Tables/FeatureServer/3','matches','site','${siteid})

 

I am able to use a script to return all the assets for a site in json and could format that as needed. But, don't know how to use that to populate the select_multiple.

No idea where I'm going wrong and I've spent way too much time on this. Any help would be greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
MichaelKohler
Occasional Contributor II

My issue was the inconsistent field naming across the different items. In order for this to work, the search field name has to be used everywhere. My search field name was property and the key to the tables was siteid.

The hosted table and the csv table had to have a field named siteid and property. In the choices spreadsheet, there had to be a row for the select_one property      see choices.png

In the survey row for the select_one property, the formula in the appearance column is below

autocomplete search('property?url=https://services1.arcgis.com/*/arcgis/rest/services/PropertyTables/FeatureServer/3','matches','site',${siteid})

 the table parameter in the search function has to start with property as well.

to get the same result from the csv file

autocomplete search('PropSched','matches','site',${siteid})

 

And thanks to Tyler for pointing out my rogue apostrophe.  🙂

View solution in original post

0 Kudos
3 Replies
JoseBarrios1
Occasional Contributor III

Hello Michael,

I've used a similar approach in the past. Your expression looks correct to me. You are using the search on the appearance field right? Could you share your CSV file so I can take a look?

JB

0 Kudos
TylerGraham2
Occasional Contributor

What you've got in your example is '${siteid}.  Remove the rogue apostrophe so it is just ${siteid} and try it again.  

MichaelKohler
Occasional Contributor II

My issue was the inconsistent field naming across the different items. In order for this to work, the search field name has to be used everywhere. My search field name was property and the key to the tables was siteid.

The hosted table and the csv table had to have a field named siteid and property. In the choices spreadsheet, there had to be a row for the select_one property      see choices.png

In the survey row for the select_one property, the formula in the appearance column is below

autocomplete search('property?url=https://services1.arcgis.com/*/arcgis/rest/services/PropertyTables/FeatureServer/3','matches','site',${siteid})

 the table parameter in the search function has to start with property as well.

to get the same result from the csv file

autocomplete search('PropSched','matches','site',${siteid})

 

And thanks to Tyler for pointing out my rogue apostrophe.  🙂

0 Kudos