Airtable for Fibre People

If you’ve found my videos and scripts useful, I would really appreciate if you used my referral link to sign up to Airtable. I will get $10 Airtable credit for each person who completes their account verification.


If you would like to copy my base, you can access the template here. Once added to your Airtable Workspace, please duplicate it to start your own base.


Airtable for Fibre People series on YouTube


Below are the two scripts I created to 1) Create a Project record from a Queue record and delete the Queue record and 2) Autopopulate the Project/Yarn junction table (which allows tracking of yarn qty used per project) from the Project record.

To use these scripts, you need to install the Scripting app in the Apps area of your base and create two Dashboards (one to house each script). Copy the relevant script into the script editor.

Then have a Button type field on your Queue table and Projects table, Action is Run Script, and choose the relevant Dashboard and then Scripting, as per below screenshot:

For more details, see the third video of the Airtable for Fibre People series linked above.


Script code to Create Project from Queue record

// Change this name to use a different table
let table = base.getTable("Queue");
// Prompt the user to pick a record
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', table);
let projectsTable = base.getTable('Projects');
if (record) {
// The following script creates a record on the Project table (defined above),
// and fetches and prefills the data from the Pattern, Yarn and Name fields,
// and sets the Start Date field value to today's date, and the Status to In Progress
await projectsTable.createRecordAsync({
"Pattern": record.getCellValue('Pattern'),
"Yarn (from stash)": record.getCellValue('Yarn'),
"Name": record.getCellValue('Pattern Name'),
"Start Date": new Date(),
"Status":{name: 'In progress'},})
output.text(`Project created: ${record.name}`);
// the following command deletes the record from the Queue table
await table.deleteRecordAsync(record);
} else {
output.text('No record was selected');
}

Script code to Autopopulate Project/Yarn Junction Table from Project record

// Change this name to use a different table
let table = base.getTable("Projects");
// Prompt the user to pick a record 
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', table);
let populateTable = base.getTable('Project/Yarn');
let linkedRecordCellValue = record.getCellValue('Yarn (from stash)');
for (let yarn of linkedRecordCellValue) {
// The below creates a record on the Project/Yarn table and populates
// the Project and Yarn fields with the data from the Project record
    await populateTable.createRecordAsync({
        "Project": [{id: record.id}],
        "Yarn used": [{id: yarn.id}],
        })
    output.text(`Records created: ${record.name}, ${yarn.name}`)
}