Skip to main content
Solved

Creating a individual records based on a range

  • January 23, 2026
  • 22 replies
  • 171 views

Forum|alt.badge.img+2

I’d like to build a base to track our produce prescription program. We have coupons with barcodes to distribute to the patients. Ideally I’d like the health worker to use a barcode scanner to scan the first coupon and the last coupon for each patient. Then I need to populate a table of all the coupons distributed within that range for each patient. 
I currently have a table set up for “patients” where health workers would assign the coupons. Then I have a table for “Coupons” where I’d like the records to be each coupon code distributed. 

Any help in how to do this would be appreciated!

Best answer by TheTimeSavingCo

What I’m trying to figure out is having other values input with the coupon range (clinic and distribution date) that also auto populate with each coupon record when the automation runs in the distribution tab.

Yeap that’s working fine as far as I can tell!

 

22 replies

TheTimeSavingCo
Forum|alt.badge.img+31

Yeap should be doable, probably write a simple script to help you create the range.  Could you provide an example of the first and last coupon, and the range that would need to be created / rules for creating that range?

Once I have those I’ll see what I can do!

---

I take it the scanning of the first and last coupon bit are working fine?


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 26, 2026

@TheTimeSavingCo  I haven’t received my barcode scanner yet to test. My plan is to have a form for the health care provider to input the patient ID number and then one field to scan the first barcode, and a second field for the last barcode number.
The barcodes will be distributed in numerical order and each patient receives a different number of coupons depending on their household size. So the rules for the range is simply the first barcode number plus one until you get to the last barcode number. Each barcode within that range would be associated with the same client ID number submitted in the form.


TheTimeSavingCo
Forum|alt.badge.img+31

Ah yeah that’s pretty straightforward and I’ve set it up here for you to check out

 

Here’s how the automation looks:


And it works by using a Script action to create an array of each increment, then we use a Repeating Group on the result to create one record per increment

let { start, end } = input.config();

const out = [];

for (let i = start; i <= end; i++) {
out.push(i);
}

output.set("result", out);

 


Flow Digital
Forum|alt.badge.img+2
  • Participating Frequently
  • January 27, 2026

Hey ​@LEAP4Local 

I hope you were able to do that  based on the suggestion from TheTimeSavingCo, you can share an update here for learning purposes.


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 27, 2026

Ok, I’m so close but I seem to be missing something. I have adjusted the trigger to be for when a form is submitted instead of when a condition is met, but I don’t know why that would be the issue. The automation is running (records are added in the new table) but no values are being entered, it’s just a blank table with a lot of lines.


DisraeliGears01
Forum|alt.badge.img+21

So compared to the gif Adam included, the issue is that the records generated are unnamed (blank) instead of 500, 501, 502, etc? Is it producing the right number of attached blank records?

My first thought is what’s the primary field for your barcode number table? If it’s a formula or an autonumber, those aren’t editable fields and so when it creates the records it can’t write a number into the primary.


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 27, 2026

Correct. They are blank and they are the correct number of records. The primary field for the second table is #. 

 


johov
Forum|alt.badge.img
  • New Participant
  • January 27, 2026

Hi ​@LEAP4Local ,

 

I can see from your screenshot that the issue is in your "Create record" configuration - the "# ID" field is selected but the value is empty (blank)!

 

You need to map the current item from the Repeating Group to that field:

 

1. Click on the empty value area next to "# ID"

2. Click the blue "+" button to insert a dynamic value

3. Look for the Repeating Group section and select the current item - this contains each number (500, 501, 502...) from your script's output

 

Once you map that current item to the ID field, each record created will get the correct coupon number instead of being blank.

 

Hope that helps!


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • January 27, 2026

Beautiful! Thanks for all the help everyone!
Now...is there a reason the numbers are coming in out of order?

 


DisraeliGears01
Forum|alt.badge.img+21

Automations and scripts run all at once and just with the way Airtable processes things they end up popping in at (very slightly) different times. If you just add a Sort by ID they’ll be in order (Airtable doesn’t really care about row order the way Excel does). 


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 16, 2026

What is the best way to pull in the data from the clients tab to the corresponding coupon ID in the distribution tab? I essentially would like the distribution tab to the the same data as clients but be listed by coupon (based on the range in clients table) without having to select a linked record.

So the picture is the data I want to have in the Distribution table but without having to select the record in the clients column.

 


TheTimeSavingCo
Forum|alt.badge.img+31

Hm, could you provide some screenshots of how your data’s setup?

In my head, each Transaction (record containing the start and end range of coupons) would be tied to a Client, and so we’d just add a lookup field to the Distribution table to grab the Client

 


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 17, 2026

Data is submitted in a form to the Client table: 
 

A script takes the range from the client table and lists them out as individual records in the distribution table: 
 

Right now I have to select the record in the clients column to get the lookup columns to work. I’d like them to auto-populate without me having to click through each one.


TheTimeSavingCo
Forum|alt.badge.img+31

Ah, in your ‘Create record’ automation, add the linked field to your Clients table and use the triggering record’s record ID.  That’ll link each created record to the Client


So your Clients table already contains the coupon ranges?  What happens if the same client comes again?  They get a new ‘Client ID’ value?


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 19, 2026

Here is the Clients table:

Here is the Distribution table:
 

When I try to set up that additional field to the automation, the only record I can select to link to is “current item” not “airtable record ID.”

There will be more than one entry per client. They get coupon distributions every two weeks. That is why the records in the client field are a formula instead of the client ID number.


TheTimeSavingCo
Forum|alt.badge.img+31

When I try to set up that additional field to the automation, the only record I can select to link to is “current item” not “airtable record ID.”
Hm, could you provide some screenshots of how you’re trying to add in the record ID?  This is what it looks like for me when I do that!


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 23, 2026
Here is the current automation set up. The first field uses data from “current item.” 
When I add a second field for Clients, and use the same data source (current item), “array value” is the only option. If I switch to data from “when a form is submitted” and select “airtable record ID” then I get the error message “Could not find matching rows for string.”

 


TheTimeSavingCo
Forum|alt.badge.img+31

If I switch to data from “when a form is submitted” and select “airtable record ID” then I get the error message “Could not find matching rows for string.”

Hm, and the form is submitting to the table that’s linked via the ‘Clients’ field? 

Could you duplicate your base without any data in it and DM me an invite link?  


TheTimeSavingCo
Forum|alt.badge.img+31

Thanks for the link!  I just tested and it worked fine?  I’ve also DMed you a link to the base where I tested it so that you can compare the two if that helps!

And here’s the automation setup:


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 25, 2026

Yes, the automation of the coupon range into individual records works fine. What I’m trying to figure out is having other values input with the coupon range (clinic and distribution date) that also auto populate with each coupon record when the automation runs in the distribution tab. Whether that’s part of the script, or another automation, or somehow using a lookup field is where I get lost.


TheTimeSavingCo
Forum|alt.badge.img+31

What I’m trying to figure out is having other values input with the coupon range (clinic and distribution date) that also auto populate with each coupon record when the automation runs in the distribution tab.

Yeap that’s working fine as far as I can tell!

 


Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • February 26, 2026

This works beautifully. I still don’t understand why I wasn’t able to do this but thank you so much!