Auto Create X Number of Records

Is it possible to get AirTable to generate X number of records in a table?


Table: Batch
Col: Date
Col: Batch Number
Col: # of Units Produced

Table: Units
Col: Batch Number
Col: Serial Number

I’d like to create a record in Batch table, and if I say 10 units were produced in that batch, then automatically 10 NEW records appear in Units table (all of them linked to their batch in the Batch table) and all of them assigned automatically a sequential number (starting number would be MAX of whatever serial number is already in tab from PREVIOUS batch).

I can’t even begin to wrap my head around this one.

So, the two main issues would be automatically creating X records based on the event of another table AND auto generation of serial numbers starting off at the last serious number of previous batch.

Is this impossible?

It’s not impossible. To do it natively inside of Airtable will require the Scripting block. You could add a button field onto your [Batch] table. Clicking that button would trigger a script that would make the new records in the [Units] table, assigning them the correct numbers and linking to their related batch record. To prevent a batch of units from being made twice, you could add a {Units Created} date field on the [Batch] table, which would be filled by the script once it’s done making and linking the units. If you accidentally click the button again, it would check the field first, and alert you if it finds a date. It’s not total hands-off automation, but it’s all within Airtable.

This could also be done using an integration service like Zapier or Integromat. It might be a little trickier to set up, and it would run on a set schedule (between 1 and 15 minutes, depending on your account level), but it could be completely hands-off if that’s what you prefer.

If you’d like help with either set up, let me know and I’ll be glad to assist!

Hi Justin,

Thanks for the reply! I’d be very interested in learning more. I would prefer the easier method to implement, only because I’m very new to all of this and can get lost easily.

To make this even more complicated, after the X records are created in the Units table, I’d like those newly created records to be auto exported into CSV file. Basically, not only am I creating a log of units that will have their own serial numbers (for use with barcode/QR code) but the export allows me to take those new units and dump that file into my label printer to easily print a batch of labels off of the new records.

Hopefully that made sense.

You mentioned this will use scripting. When I added a script block it mentioned users will have access to this until September of 2020. Does that mean this feature is being phased out?

That message popped up because your base is in a Free plan workspace, where access to the Scripting block ends in September. Bases in a Pro plan or higher workspace can use all blocks all the time.

That’s going to be a problem. Airtable cannot auto-export anything because it has no built-in automation features. Even if it did, it’s is a web-based service, and any output from a website to a file on your local machine requires user intervention, even if it’s only to specify where to save a file.

There are a couple of ways around this that come to mind. One would be to use the Page Designer block to design and print your labels directly from Airtable. Another would be to have the CSV file created as part of the Integromat scenario that does the record creation and linking mentioned previously. The file could be saved to Google Drive, Dropbox, or another service of your choice, where you can access it for printing. I don’t have experience making CSV files on the fly like this, though, so I can’t offer specific tips on how to pull it off. My recommendation would be to use the Scripting block to build the records, and the Page Designer block to print the labels.

I feel that scripting is probably going to be the easier of the two options. I suggest going through the various examples that the Scripting provides to see how the code is designed and to learn the kinds of things you can do. If you run into any problems, start a new thread in the #scripting-block category and we’ll be happy to help. If you’d rather hand over the scripting to someone else, message me and we’ll talk details.

Hi Justin,

Plan: Hmm, that’s odd. I am currently paying for the pro plan.

CSV: No problem. Manually exporting the CSV file is easy enough.

Scripting: I will take a stab at getting my feet wet with scripting. I won’t get too far, so you’ll be seeing my posts shortly in #scripting-block. Haha! Thank you for all your input, I appreciate it! :slight_smile:

Just as a reminder, plans are assigned at the workspace level. If the base where you add the Scripting block isn’t in a Pro plan workspace, then it can’t use Pro plan features. I’m not sure if that’s your issue here, but that’s what comes to mind based on our conversation so far. If that’s the case, you could always move the base into the Pro plan workspace at any time. There’s no penalty for moving bases between workspaces with different plans.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.