Hi Airtablers!
This is a silly little thing that I though some others might find useful/funny. I find myself living in my ‘demo’ base most of the time. Users come to me with an Airtable question and I often open my demo base and recreate the issue to help them solve it.
When I do this I often need to make a few tables and fields quickly, yet creating a new table, naming it, renaming the primary field and deleting Notes, Attachments and Status every time is a pain.
So here is a small script to keep at the top of your extensions to quickly create new tables and fields without the need to clean them up after.
const config = input.config({
title: 'New Table Maker',
description: 'This script lets you create a new user defined table without the default table options.',
items: m
input.config.text('defaultPrefix', {
label: 'Default New Title Prefix',
}),
input.config.select('keySuffix', {
label: 'Title Suffix',
description: 'A unique number to append to the Title',
options: n
{label: 'Current Date/Time', value: 'curDate'},
{label: 'Random Number', value: 'ranNum'}
]
}),
input.config.text('keyName', {
label: 'Default Title of the Primary Field',
}),
input.config.select('keyType', {
label: 'Type of field for the Primary Field',
description: 'Select the field type',
options: n
{label: 'Single Line Text', value: 'singleLineText'},
{label: 'Long Text', value: 'multilineText'},
{label: 'Phone Number', value: 'phoneNumber'},
{label: 'Email', value: 'email'},
{label: 'URL', value: 'url'},
{label: 'Barcode', value: 'barcode'},
]
}),
input.config.text('fieldName', {
label: 'Field Name',
})
]
});
const defaultPrefix = config.defaultPrefix;
const keyName = config.keyName;
const fieldName = config.fieldName;
const keyType = config.keyType;
const keySuffix = config.keySuffix;
let fieldString = '{name: "Field", type: singleLineText}';
let createdDate = Date.now();
let randomNumber = Math.floor(Math.random() * 100000);
if(keySuffix == "curDate"){
const tableId = await base.createTableAsync(defaultPrefix+createdDate, t{name: keyName, type: keyType},{name: fieldName, type: "singleLineText"}]);
}
if(keySuffix == "ranNum"){
const tableId = await base.createTableAsync(defaultPrefix+randomNumber, e{name: keyName, type: keyType},{name: fieldName, type: "singleLineText"}]);
}