Sep 07, 2020 09:08 PM
Can the buttonAsync be created dynamically?
I have an array of Order Numbers called filteredOrderNames. Can each value of the array serve as the button label?
let selectedOrder = await input.buttonsAsync(
'Select Order Group from List below',
[
{label: filteredOrdersNames, value: filteredOrders}
]);
Solved! Go to Solution.
Sep 07, 2020 09:28 PM
Yes, this can be done using the map
method on the filteredOrdersNames
array. Here’s a test I just ran:
let filteredOrdersNames = ["One", "Two", "Three", "Four", "Five", "Six"];
let filteredOrders = [1, 2, 3, 4, 5, 6]
let selectedOrder = await input.buttonsAsync(
"Select order group from list below",
filteredOrdersNames.map(item => {return {label: item, value: filteredOrders[filteredOrdersNames.indexOf(item)]}})
)
output.text("Selected Order: " + selectedOrder)
Output:
Sep 07, 2020 09:28 PM
Yes, this can be done using the map
method on the filteredOrdersNames
array. Here’s a test I just ran:
let filteredOrdersNames = ["One", "Two", "Three", "Four", "Five", "Six"];
let filteredOrders = [1, 2, 3, 4, 5, 6]
let selectedOrder = await input.buttonsAsync(
"Select order group from list below",
filteredOrdersNames.map(item => {return {label: item, value: filteredOrders[filteredOrdersNames.indexOf(item)]}})
)
output.text("Selected Order: " + selectedOrder)
Output:
Sep 08, 2020 05:37 AM
This is brilliant! Thanks so much. It works perfectly.
Aug 13, 2024 11:54 AM
4 years later and this post helped me out SO much! Thank you!