How to Auto-Generate a Barcode for New Records in Airtable

If you're managing inventory, check-ins, or anything that involves scanning items, Airtable's barcode field can be incredibly helpful. It allows you to scan items in and out using the mobile app, making your workflow faster and more efficient.

Let’s say you're trying to automatically generate a unique barcode using an automation. You want to create a 13 digit number for each new record, print it as a label, and stick it on your items.

You write a script that generates the number, and it runs perfectly. But when it's time to save that value into the barcode field, nothing happens. The field stays empty.

Strangely, the exact same script works fine if you update a Short Text or Long Text field instead.

Illustration

So why does this happen? Why does it fail when writing to a barcode field?

This happens because Airtable does not let you update a barcode field directly from a script. Even if your script runs successfully and creates the right value, it will not write it into the barcode field. That is just how barcode fields work in Airtable.

So what can you do instead?

The solution is to output the value from your script, and then let the automation handle the update. Inside your script, use the output.set() function to pass the barcode value to the next step in your automation.

output.set("barcode", barcode);

This stores the barcode number with the key "barcode".

Now, in the next step of your automation, add an Update record action. Select the record you are working with. Then, for the "Barcode" field, click "Dynamic" and choose the barcode value from the script step. You should see the "barcode" key there. Select it.

This works because the script is not trying to write to the barcode field directly. Instead, the automation step is doing it, and Airtable allows barcode fields to be updated this way.

In short, let the script generate the value, and let the automation do the writing.

Get Airtable tips & tutorials

Get a concise Airtable tip or tutorial every week. No spam—just practical advice to help you get more from Airtable.

Need help or have feedback? Email me at[email protected]