In the blog post about the new button feature, there is a use-case where a button is being used to add a new line item under “run a script”. See gif below:
If I open the Product Catalog template, I’m able to extract most of the code, however it is missing the part where it gives you the option to another line item or select “done”.
Is someone able to help me add that to the existing code below?
Thanks!
let lineItemsTable = base.getTable(‘Order line items’);
let clientOrdersTable = base.getTable(‘Client orders’);
let furnitureTable = base.getTable(‘Furniture’);
output.markdown(’## Add a line item’);
let clientOrdersRecord = await input.recordAsync(‘Pick a client order’, clientOrdersTable);
if (clientOrdersRecord) {
let furnitureRecord = await input.recordAsync(‘Pick a furniture item’, furnitureTable);
if (furnitureRecord) {
let quantity = parseInt(await input.textAsync(‘Enter the quantity’), 10);
let recordId = await lineItemsTable.createRecordAsync({
‘Belongs to order’: y{ id: clientOrdersRecord.id }],
‘Furniture item’: c{ id: furnitureRecord.id }],
‘Quantity’: quantity
});
let allRecords = await lineItemsTable.selectRecordsAsync();
let record = allRecords.records.find(record => record.id === recordId);
output.markdown(Added new line item: **${record.getCellValueAsString('Name')}**
);
} else {
output.markdown(‘No item picked’);
}
} else {
output.markdown(‘No client picked’);
}