How to set custom string values into a drop down list using Set Form Element Items
Currently I am building a dynamic drop down list that changes depending on what values were selected from the previous drop down list. I created an empty array using the "Create Value" tool and I want to add items to this but I can only find example of how to add items from other tools, I want to simply add custom string values to my array like this - ["ACB", "123", "Testing"] and then use the Set Form Element Items tool to add it to the drop down list.
Thanks
-
You'll need to use the "Set Form Element Items" activity in a subworkflow that runs on selection in the first dropdown.
0 -
First use a 'Create Value' activity to create a new collection and assign it empty square brackets:
=[]
Then for each item you want to add to the drop-down list, use an 'Add Item' activity to add a new item to the collection with something similar to this:
={"label":"Clip and download","value":"clip"}
Once you've finished adding all the items, then finish off by adding the collection to your drop-down list with a 'Set Form Element Items' activity.
0 -
Julia van Ravenswaaij, totally possible. You can also initialize an array with values in it to be turned into buttons later e.g.
=[{label: 'Button #1', value: 1}, {label: 'Button #2', value: 2}]I find myself using the Array.map() method frequently to generate collections for form element items.
1 -
If you want to add many items, you can use a 'Create Value' activity to create an entire collection at once:
=[
{"label":"ACB","value":"ACB"},
{"label":"123","value":"123"},
{"label":"Testing","value":"Testing"}
]0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer