Can you programatically change the Where clause of a Query Layer activity?
I have a form with 5 dropdown boxes that let the user select a feature based on 5 different attributes. I'd like to be able to use just one Query Layer activity to take the picked value from any of the 5 dropbown boxes, and build the Where clause using it. Is there a way of doing this? I don't want to have to do 5 separate queries...
Thanks!
Chris
-
Sure, the where property would be something like this:
=`field1='${ $form1.state.textBox1.value }' AND field2='${ $form1.state.textBox2.value }'`which results in
field1='hello' AND field2='world'If one of the values contain single quotes, you will have to replace those with siongle quotes
0 -
Thanks for the help Berend. My case is slightly different, as the user can only select from one dropdown (the others are reset as soon as a value is picked). However, I was able to solve it as follows:
- Added a Create Value activity called valueWhereClause to hold the value of the Where clause
- added a series of IF activities to figure out which dropdown was populated
- after each IF activity, used an Evaluate Expression to set the value of the valueWhereClause based on the appropriate attribute
- Each If statement then points to a common Query Layer activity. Its Where clause is set to =$valueWhereClause.result
Other than the inelegance of multiple IF activities, it does everything using a single Query Layer activity, so I'm happy.
Thanks for your help. It gave me some ideas.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer