I am very new to Airtable, and am after help with the script block. What I would like to achieve is exactly what has been given as an example here.
This is what I have written:
let lineItemsTable = base.getTable(‘Order Line Items’);
let siteOrdersTable = base.getTable(‘Label Orders’);
let productsTable = base.getTable(‘Product Inventory’);
let siteRecord = await input.recordAsync(‘Select a Site’, siteOrdersTable);
if (siteRecord) {
let labelRecord = await input.recordAsync(‘Select a Label’, productsTable);
if (labelRecord) {
let quantity = parseInt(await input.textAsync(‘Quantity’), 10);
let recordId = await lineItemsTable.createRecordAsync({
‘Job’: [{ id: siteRecord.id }],
‘Item’: [{ id: labelRecord.id }],
‘Qty’: quantity
});
let allRecords = await lineItemsTable.selectRecordsAsync();
let record = allRecords.records.find(record => record.id === recordId);
output.markdown(Added new Label Item: **${record.getCellValueAsString('Description')}**
);
let addAnother = await input.buttonsAsync(‘Add another Label’, [‘Add Another’, ‘Done’]);
if (addAnother === ‘Add Another’) {
let labelRecord = await input.recordAsync(‘Select a Label’, productsTable);
if (labelRecord) {
let quantity = parseInt(await input.textAsync(‘Quantity’), 10);
let recordId = await lineItemsTable.createRecordAsync({
‘Job’: [{ id: siteRecord.id }],
‘Item’: [{ id: labelRecord.id }],
‘Qty’: quantity
});
let allRecords = await lineItemsTable.selectRecordsAsync();
let record = allRecords.records.find(record => record.id === recordId);
output.markdown(Added new Label Item: **${record.getCellValueAsString('Description')}**
);
}
} else {
output.markdown(‘Done’);
}
} else {
output.markdown(‘No Label Picked’);
}
} else {
output.markdown(‘No Order Picked’);
}
Im not sure where or how to place the “For” loop… Any help would be greatly appreciated.