Automatically assign record to pre-existing group

Topic Labels: Automations
933 3
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello all,

I have a database with a list of records representing people that are uploaded every month with new people coming in and people going out.

Each record (people) is assigned to a group of 5 people to share ideas and experience. I did the first repartition where People (ie records) are assigned to specific group but I am stumbling on the automation of the process.

The idea is that now, every time someone is coming in, I can automaticaly update its record with the group he or she is assigned to (meaning assigned to the first group with less than 5 people in it).

I tried numerous formulas and automations without success...did anyone have any suggestion on how I could do so ?

Thanks for your help !



3 Replies 3

Hmm, do you have an Airtable Pro plan?  Does it matter whether you assign the person to the group that has only had 4 users the longest?

Thank you for your reply ! Yes I do have a pro plan.
No it does not really matter for the duration, the automation could pick any group that has less than 5 

Roger that.  I would suggest:
1. Create a count field in the "Groups" table that displays the number of people linked to the group
2. In the automation that triggers when a new "Person" record gets created, add a "Find Record" action that'll look for all gorups that have <5 people in it
3. Add a "Run script" action with the following code:

const {foundRecords} = input.config()


if(foundRecords.length > 0){
  output.set("record", foundRecords[0])
  throw "No groups with less than 5 members"

4. Add the input variables on the left so it looks like the following screenshot:

Screenshot 2023-06-29 at 7.13.43 PM.png

5. Add an "Update record" action that'll update the triggering record's (i.e. the "Person" record) linked field to the "Group" table with the ID from the script step

The script basically pulls the first group from the "Find Record" action if it found any groups that have less than 5 members, and if the "Find Record" action didn't find anything it'll throw an error

If you DM me an invite link I can set it up for you real quick, or we could also do a quick screenshare where I set it up for you too.  Best of luck