Aller au contenu principal

Use a Variable in Query Layer Where Clause

Commentaires

7 commentaires

  • Victor Catalán

    You need to use an expression to be able to use a variable.
     

    To replace the variable my suggestion is to use Javascript Template Strings

    =`FSKALB = ‘${$workflowInputs.inputs.FSKALB.toString()}’`

    Or you can olso use the old mode

    ="FSKALB = '" + $workflowInputs.inputs.FSKALB.toString() + "'"

    1
  • Sven de Haan

    Victor Catalán oh wow thank you! Works like a charm with the old mode. The first didnt work for me. Maybe some of the inverted commas in your first recommendation gets destroyed when i copy it?

    But thanks for the fast solution! Alot to learn about this syntax in VertiGIS Studio Workflow :D

    0
  • Victor Catalán

    I am happy to help! You must always remember to use expressions in any workflow input with the equality operator. Then they are simple JS expressions. Surely you will get into this :)

    1
  • Ken Lyon

    Sven de Haan , I'm not sure if your workflow is intended for production use, but I would caution you about the current structure. As it stands, it is a prime candidate for a SQL injection attack. You have a value passed in via the query string which is then concatenated with the other part of the WHERE clause.

    It would be wise to clean the value in some way, such as escaping any quote characters.

    This cartoon is my favourite explanation of SQL injection:

    (Source)

    1
  • Berend Veldkamp

    Ken Lyon I would assume that the where-clause in a Query Layer activity (or rather, the service's /query endpoint) is safe enough for those scenarios? After all, we can just bypass the viewer/workflow and open the rest endpoint in a browser directly to query for Bobby Tables.  

    Of course it's a different story if a Run SQL Query Unsafe activity is used

    And it's always a good idea to do at least some sanity checks on user input.

    0
  • Ken Lyon

    Berend Veldkamp You're right - there's likely some escaping that happens within the Esri API prior to actually executing the query. The Run SQL Query Unsafe activity would certainly be a different story.

    Still, the pattern just got my spidey senses tingling. :)

    0
  • Sven de Haan

    Hi Victor Catalán i got another question about this. In some cases the URL contains multiple FSKALB or FSK values. For example: “&workflowParams={”FSK":"000000000000000001__;000000000000000002__"}

    How can i handle this? I want to highlight all values in the URL in the map with the workflow.

    My idea is to split the values and then query over each value and then scale to the map at the end. But with this low-code system from VertiGIS Studio Workflow its hard for me to get a startpoint here :'D

    Thanks!

    0

Vous devez vous connecter pour laisser un commentaire.