Hoppa till huvudinnehållet

Create array of "label" from Item Picker (to pass to Report)

Kommentarer

4 kommentarer

  • Berend Veldkamp

    The selected items are in the array $form1.state.itemPicker1.value.items.

    To get just the labels from those items, you could use a For Each loop on those items and inside it, use Add To Collection to add the label to an array variable.

    Personally, I find For Each to be quite cumbersome and slow, so I usually write some JavaScript, e.g. like this:

    =$form1.state.itemPicker1.value.items.map(x => x.label)

    This will return an array of the label property of each selected item, which can go directly in the Feature ID's of the report activity.

     

    (Note: I always thought a report required the objectid values, but if this value works for you, then this is the way)

    3
  • Alexander Bureaux

    That's amazing, thank you! That function worked beautifully, and I was finally able to run my report (so cool). 

    In case anyone in the future stumbles across this, I'll include a picture:

    Regarding the report, I am still a novice, but I have worked with Report more in the past and am a little more comfortable with that. My understanding of its ID requirement is that the main report requires “FeatureID”, which is a reserved word set by VertiGIS, and that we can feed any value into FeatureID via the “Edit query” button. So long as the value you feed into it is unique, you should get a good report.

    In my case, the ID you see above is our internal equivalent of an OID. It's a random and unique value. Now, why did I choose this over OID? Not sure… I was playing around with a bunch of different options in Workflow and kind of just landed on it. I may swap to OID in the future because it really does make a lot more sense to use it. But, since this is finally working, I'll leave it alone for the short-term.

    Thank you again!

    2
  • Amanda Putri

     

    Hi, I have similar issue except I am working with List Box instead of Item Picker. What I am trying to do in my workflow:

    • Users use Geometry Picker (free hand polygon) to select features in an area of interest
    • Then the selections are displayed in the List Box where they can select single or multiple selections from the box 
    • The IDs of the selected feature is then supposed to be passed through as input for the Run Report activity

    Similar to the original post, my report is also working correctly when I tested it using a default value. But I seem to miss something as I can't pass the selected feature IDs for the report. 

    Can this JS be modified 

    into something like this within the Create Value activity?

    The workflow for that part looks like this :

    If someone could point me to the right direction please. Thank you! 

    0
  • Zack Robison

    In case you haven't found it yet, yes you can Amanda Putri. As long as the data required is there in the list box items.

    I think the most common way that people generate list box items is from a feature set where the features themselves are the backing data for the items, in this case you would have something like (and I may be a bit off here):

    =$form.state.listBox.value.items.map(item =>  item.value.data.attributes.OID)

    You can figure out what you need by checking out the form items in question using the browser console.

    0

Du måste logga in om du vill lämna en kommentar.