Cannot understand why when I'm pressing the button it triggers the function multiple times.
Also, the event handler handleCardClick(e) returns back whole json (instead of saying what action was triggered). Any idea on what I'm doing wrong?
function testLogic(input) {
Logger.log("testLogic triggered" + input);
}
function buildCategoryCardV2(categories) {
const buttons = categories.map(category => ({
text: category,
onClick: {
action: {
function: testLogic(category),
actionMethodName: 'showCategory',
parameters: [{ key: 'category', value: category }]
}
}
}));
const card = {
cardId: 'category_selector',
card: {
name: 'Category Selector',
header: { title: 'Inventory Request', subtitle: 'Please select a category' },
sections: [{ widgets: [{ buttonList: { buttons: buttons } }] }]
}
};
return card;
}