Create array of "label" from Item Picker (to pass to Report)
Hello,
I am attempting to use Workflow to generate a Report. I am nearly there, but cannot seem to find the correct value to pass.
- I have a Workflow that selects features from a buffer. This is working.
- I have a Report that generates a… report. This is working.
- Now I am trying to pass my values from Workflow into Report. This is not working.
I started by adding a Text Box to my Workflow to manually type in a featureId:
This does what I expect, and I can see my manually entered value in the featureIds Array (and a Report is successfully generated for that one feature):
Now, I need to pass every result from an Item Picker. I am using this to grab an array of items:
But I can't figure out how to isolate just the “label” component, which is what I need to pass into Report:
-
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 -
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 -
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 -
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.
Kommentarer
4 kommentarer