Skip to main content

Simplified Filter Builder using workflow (use Check Group to filter layer by attributes)

Comments

7 comments

  • Niluka Munasinghe

    Hi Amanda,
    If the layer is already on the map, first ensure that the layer is visible (Set Layer Visibility). Then, create a definition query based on the user's selection and apply the definition expression to the layer (Set Layer Definition Expression). There's no need to query the layer at all.

    1
  • Amanda Putri

    Hi Niluka Munasinghe your response is much appreciated! 

    So the layer is already visible for now, I scrapped the 3 activities I used previously and replace it with the Set Layer Definition Expression as you suggested. It looks like this now:

    Using this expression 

    =`MARK_TYPE= '${$GDA2020filter.state.checkGroup1.value.items}'`

    but it still won't filter out the features. The developer tool shows this error message but I am not sure I understand what that means.  

    0
  • Niluka Munasinghe
    {"_properties":{"isServerWorkflow":false},"components":[{"id":2,"steps":[{"id":3,"inputs":{},"position":"0,-130","purpose":"start","title":"Start","transitions":[{"id":15,"position":"90,-70 90,0","sourceConnector":"bottom","target":{"id":14}}]},{"action":"gcx:wf:forms:form:DisplayForm","id":4,"inputs":{"form":{"accessors":[],"code":"resources.forms[values.id]","values":{"id":5}}},"name":"form1","position":"-30,110","title":"Display Form","transitions":[{"id":11,"position":"90,230 90,280","sourceConnector":"bottom","target":{"id":7}}]},{"action":"gcx:wf:core:loop:ForEach","id":7,"inputs":{"items":{"accessors":["$form1"],"annotations":[{"count":6,"index":0,"kind":"idref"}],"code":"$form1.state.checkGroup1.value.items","source":"$form1.state.checkGroup1.value.items"}},"name":"forEach1","position":"-30,280","title":"For Each","transitions":[{"id":21,"position":"90,400 90,450","sourceConnector":"bottom","target":{"id":20}}]},{"action":"gcx:wf:core::CreateValue","id":14,"inputs":{"expression":{"accessors":[],"annotations":[],"code":"[]","source":"[]"}},"name":"checked_values","position":"-30,0","title":"Create Value","transitions":[{"id":16,"position":"90,60 90,110","target":{"id":4}}]},{"action":"gcx:wf:core::CreateValue","id":20,"inputs":{"expression":{"accessors":["$checked_values"],"annotations":[{"count":15,"index":18,"kind":"idref"}],"code":"\"MARK_TYPE IN ('\".concat($checked_values.result.join(\"','\"), \"')\")","source":"`MARK_TYPE IN ('${$checked_values.result.join(\"','\")}')`"}},"name":"SqlQuery","position":"-30,450","title":"Create Value","transitions":[{"id":23,"position":"90,510 90,560","sourceConnector":"bottom","target":{"id":22}}]},{"action":"gcx:wf:arcgis::SetLayerDefinitionExpression","id":22,"inputs":{"expression":{"accessors":["$SqlQuery"],"annotations":[{"count":9,"index":0,"kind":"idref"}],"code":"$SqlQuery.result","source":"$SqlQuery.result"},"layerId":"Your Layer Name"},"name":"layerDef1","position":"-30,560","title":"Set Layer Definition Expression"}]},{"id":8,"steps":[{"id":9,"inputs":{},"position":"0,0","purpose":"start","title":"For Each","transitions":[{"id":13,"position":"90,60 90,110","sourceConnector":"bottom","target":{"id":12}}]},{"action":"gcx:wf:core::If","id":12,"inputs":{"condition":{"accessors":["$forEach1"],"annotations":[{"count":9,"index":0,"kind":"idref"}],"code":"$forEach1.item.checked","source":"$forEach1.item.checked"}},"position":"30,110","title":"If","transitions":[{"branch":"true","id":19,"position":"30,140 -70,140 -70,240","sourceConnector":"left","target":{"id":18},"targetConnector":"top"}]},{"action":"gcx:wf:core::AddItem","id":18,"inputs":{"collection":{"accessors":["$checked_values"],"annotations":[{"count":15,"index":0,"kind":"idref"}],"code":"$checked_values.result","source":"$checked_values.result"},"item":{"accessors":["$forEach1"],"annotations":[{"count":9,"index":0,"kind":"idref"}],"code":"$forEach1.item.value","source":"$forEach1.item.value"}},"position":"-190,240","title":"Add Item"}]}],"deploymentConfig":{"supportedApps":{"VSW":true}},"designerVersion":"5.39.0+33","forms":[{"defaults":{},"elements":{"checkGroup1":{"enabled":true,"index":0,"items":{"0":{"index":0,"label":{"markdown":"CheckBox1"},"value":"c1"},"1":{"index":1,"label":{"markdown":"CheckBox2"},"value":"c2"},"2":{"index":2,"label":{"markdown":"CheckBox3"},"value":"c3"}},"rowIndex":0,"rowNumber":0,"type":"CheckGroup"},"footer":{"enabled":true,"items":{"0":{"default":true,"index":0,"label":{"markdown":"Submit"},"validates":true,"value":"submit"},"1":{"index":1,"label":{"markdown":"Cancel"},"validates":false,"value":"cancel"}},"section":"footer","type":"ButtonBar"},"header":{"section":"header","title":{"markdown":"Form Title"},"type":"Header"}},"id":5}],"licenseInfo":{"licenseUrl":"https://gis-prod.cimic.com.au/vertigisstudio/workflow/service/auth/license"},"start":{"id":3},"transitions":[{"branch":"loop","id":10,"source":{"id":7},"target":{"id":9}}]}
    1
  • Niluka Munasinghe

    Import the above JSON to workflow designer and build accordingly

    0
  • Amanda Putri

    Hi Niluka Munasinghe , thanks so much for pointing me into that workflow. With a bit of modification, it works really well! 

    I was wondering if there is any way to clear all the ‘Set Layer Definition’ expression that users have submitted, i.e. to show all the mark types on the map? I searched the community posts but could not find anything so far. 

    I was thinking to include a ‘Reset’ button that will reset the layer definition and clear the filtering that users do in their previous selection.

    Your help is much appreciated!

    0
  • Zack Robison

    If you want to remove a layer definition, you could try a Set Layer Definition activity with an .expression =null or ='1=1'.  Throw that thing in a ForEach which iterates your layers (or service-layer combinations) and you should be good to go.

    0
  • Amanda Putri

    Hi Zack, thanks for the tips! I ended up using Create Value to define all the survey marks types then use it in another Set Layer Definition. Yours however looks more sophisticated and simpler, will try and see how it goes.  

    0

Please sign in to leave a comment.