Skip to main content

Hi everyone! 😄

I’m trying to create a script for Airtable Automation that limits the number of records a user can create per page in Softr + Airtable. The idea is:

  • Table: Projects

  • Field that identifies the logged-in user: Criado por

  • Field that identifies the originating page: Página Acesso

  • Limit of records per user per page: defined in the script (e.g., 3)

  • Desired behavior: if the user tries to create more than the limit, the extra record should be automatically deleted.

So far, I’ve tried using Find records + Delete record in the automation, but it didn’t work as expected. I’m looking for a ready-to-use script or example that does the following:

  1. Count how many records already exist in the Projects table for the same Criado por and Página Acesso.

  2. If the count exceeds the defined limit, delete the newly created record.

Does anyone have a script that works in this scenario or can share an example adapted to this table and these fields?

Thanks! 🙏

Hey ​@Cátia Traça,

Did you try using ChatGPT for the creation of the script?

In terms of logic, you will want to TRIGGER the automation when a new record gets created. You’ll have a find records action block then, and you can then have a CONDITIONAL LOGIC which will check if length of found records on previous step is equal or bigger than X. If that is the case, then you will have the corresponding script that should delete the record that triggered the automation (you can pass this record id as config input)

If you need any help setting this up, make sure to schedule a call using this link and I can show you around. Seems you speak Spanish? I’m based out of Argentina if that helps!
 

Completely different matter, but would love to have you join our Airtable Hackathon! Make sure to sign up!!

Mike, Consultant @ Automatic Nation 
YouTube Channel


Thanks a lot for the clarification — that logic makes perfect sense.
My only doubt now is about the script itself: how exactly should I define the delete script in this case?
I’d like to delete the record that triggered the automation (from the Projects table), where the fields are “Criado por” (Created by) and “Página Acesso” (Access Page).

Also, I’m not sure how to correctly define the trigger record ID as an input variable for the script — could you please explain that part too or share an example?


Does this look right?  If so I’ve set it up here for you to check out

And you’d set the number of records per user per page here:

let {tableId, recordId} = input.config()

await base.getTable(tableId).deleteRecordAsync(recordId)

 


Thanks for sharing your automation setup — I followed exactly the same steps you showed.
The only issue is that I can’t configure the script the same way you did.
I don’t see any option to select the table ID or record ID inside the script configuration, and I think that’s why my script keeps returning an error.

Could you please explain how you linked those parts or show what the input variable setup looks like on your side?


Sure, here! 
 

You should also be able to access this when viewing the base via the invite link I believe!  If you’re still hitting issues DM me an invite link to your base and I’ll set it up for you


Ok, I can access it now, but I can’t configure it correctly. Here is the link for my table. Thanks again.