Can you use the value from an autoComplete box in a query?
I have a very simple workflow that has a form with a AutoComplete Box and I would like to query and zoom to the feature based on the value. However it fails on the query. The AutoComplete box populates correctly, but when the user hits submit, the workflow fails
I am using this as my where clause: =`FULL_ADDRESS= '${ $form1.state.autoComplete1.value}'`
In the dev console the where clause in the query is this when I run the workflow:
where:"FULL_ADDRESS= '[object Object]'"
It doesn't seem to be passing the value correctly. If I use a text box instead of the autocomplete it works perfectly fine. I think I am missing something, and it is probably something simple but I can't find it.
Has anyone else successfully been able to query using an AutoComplete?
-
Hi Ali,
When you use the Autocomplete box, are you typing the full text and then clicking submit, or are you typing a few characters, selecting an option from the suggestions list, and then clicking submit?
The .value property only contains a value if you've selected an item from the suggestions list. It corresponds to the Value Field Name from the Get Form Element Items From Features activity inside the Autocomplete's suggestions subworkflow.
If you type text into the Autocomplete box and then don't use the suggestions list, you can still get that text from the .label property instead. Ie, $form1.state.autoComplete1.label
0 -
Thanks Amanda for the reply. Yes I was aware of this difference. If I type in the AutoComplete and do not use a suggestion, and I change my workflow to use $form1.state.autoComplete1.label then it works.
If I am selecting from the suggestion list and use $form1.state.autoComplete1.value in my query it fails.
0 -
I wonder if it might have something to do with the way the values are populated then in the subworkflow for the Autocomplete suggestions. For example, maybe we're missing something on the "Output Fields" or "Value Field Name" properties. If it looks good in the workflow, I'd recommend tossing in some log activities to double check the values from the Query Layer and Get Form Element Items From Features activities.
Eg,
Log: =$query1
Log: =$formElementItems1
Then check your browser console logs when you use the autocomplete and see if the problem can be traced back that far or not.
Or if your service is public you could share the workflow so we can take a look.
0 -
Thanks Amanda! That was the issue. I had the Value Field Name incorrect.
My workflow works well now.
Thanks!
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer