How do you run a query from user input?
I have a text box (textBox1) on my form (form1) and I'm trying to run a query in the onChange event from what the user entered, but the variable doesn't work. Here is my where clause:
="propertyid='$form1.state.textBox1.value'"
What should the where clause look like?
-
Hi Ethan,
Your where clause has to mix both plain text (strings) and the output value from the textbox. Anything in double quotes is interpreted as a text string, and not as a reference to an activity output.
There's a couple options for formatting:
- ="propertyid='" + $form1.state.textBox1.value + "'"
- =`propertyid='${$form1.state.textBox1.value}'"`
The first one uses concatenation, the second uses template literals, where anything inside a ${} token is interpreted as an expression instead of a string.
0 -
There's a relevant docs page here as well- https://docs.geocortex.com/workflow/latest/help/Default.htm#wf5/help/expressions.htm#Use_String_Expressions%3FTocPath%3DExpressions%7C_____2
0 -
Thanks. All the examples had the template literal style and it threw me off. Makes sense now.
0 -
I'm finding the literal style is very inconsistent. Sometimes it works and sometimes it doesn't. I had it in two queries in a single workflow and when I ran it, it worked on one and not on the other.
0 -
Hi Ethan,
If you'd like to share a copy of your workflow here, I could take a look and see if I can find anything wrong with the second query or its template literal expression. You can export a copy of a workflow from File > Export in the designer, and attach it to a community post using the paperclip icon below the reply box.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
5 Kommentare