Help

Re: Random assignment of a column value

1375 0
cancel
Showing results for 
Search instead for 
Did you mean: 
diaanehme
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there,
I need some help, I’m new on Airtable!

I’m trying to solve a college test.

I have created tables with forms, when filling out the forms and updating the tables I would like to have a button that randomly assigns me roles.

Gestore

FORM 1

GestTable

TABLE 1

Giocatore

FORM 2

PlaTable

TABLE 2

I created an automation to give a value Resistance to the Role column.

I have to write a script that randomly assigns a role for each record, the role can be Resistance or Spy.

The total number of roles depends on the total number of players. The total number of players is found in another table.

If the total number of players is 5 then 3 records must have a Resistance role and the other 2 Spy.
If the total number of players is 6 then 4 records must have a Resistance role and the other 2 Spy.
If the total number of players is 7 then 4 records must have a Resistance role and the other 3 Spy.
If the total number of players is 8 then 5 records must have a Resistance role and the other 3 Spy.
If the total number of players is 9 then 6 records must have a Resistance role and the other 3 Spy.
If the total number of players is 10 then 6 records must have a Resistance role and the other 4 Spy.

Thank you in advance!!!

3 Replies 3

Hi,

check tutorial example how to perform simple read/write operation on a table

here - how to use buttons

write your script

hint: I would create array
Roles=[‘Spy’, ‘Spy’, ‘Res’, ‘Res’, ‘Res’, ‘Res’, ‘Spy’, ‘Res’, ‘Res’, ‘Spy’]
then randomly sort your query result and assign these values to it, from first, no matter how much is total.

Can you please clarify if writing the script is part taking the test? If this is a test, how much outside help are you allowed to use?

diaanehme
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you both for having answered !!

In reality it is not really a test, it is something to do and to give to a teacher.
I just have to be able to solve it.

I will be using the tables as frames in a New Google Site where players will go to play the game. Then the game manager will have to click on the “Choose Roles” button when all players are registered in the tables.

Chisei

NewGoogleSite

Then I will have to solve the problem of how can I keep the New Google Sites updated in real time when the tables on Airtable changes without clicking on refresh button. (Any ideas?)

Thank you in advance!!!