How to make dynamic text. For example: User types his name and a alert appears saying "Hello (your name)"
Hello all,
Despite managing to create some nice workflows on VertiGIS, I still struggle when I need to mix text with expressions.
I can create an alert saying whatever I want, or an alert based on the answer from a form (=$form.state.textBox.value). But how about both? How can I say "Hello (username)" based on the user input?
On an additional note, how can I make queries dynamic (Query Layer tool)? I can type "State = NY" in the Where field, but I don't know how to make that value dynamic, based on an answer from the user.
Does anyone have some guides or examples? I've been digging some tutorials (including one that uses US states as an example), but it does not give enough details.
Thanks!
-
Officiell kommentar
JavaScript Template Literals to the rescue. They use the backtick character ` and allow you to easily insert variable values into a string/text.
For example:
- =`Hello ${$form.state.textBox.value}`
- =`State = '${$form.state.textBox.value}'`
One caution on that second example that is assembling a where clause. If the textbox value contains any single quotes it'll break your where clause. Your workflow can deal with this though. There is a "Text Replace" activity that can escape them. Or if your values come from something like a drop down list you don't have to worry about it.
-
Hey Ryan, thank s a lot for your quick answer, that's exactly what I was looking for! I knew the solution would be something simple like that.
1
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer