Casually Value from 2 differents tables

Hey!! I am new to Airtable Apps. I need some help!!
How can I assign to a cell of my field casually a value from another table?
I have in my source table a field with 2 values (Resistance, Spia) and I want to choose casually one of them and then put it in my second table (Field: Ruolo), how can i do it? What script I have to write?

And then copy the value from this table to the last one?

Thanks in advance for your help!
(Sorry for my weak english!!!)

If you want to “assign” a record from one table to a record in another table you need to link them together.

In your Username/Chiave table, convert the {Ruolo} field into a Link to Record type field. Set the field up to select from your Ruolo field. Now for each record in the Username/Chiave table you will be able to select a role (ruolo) listed in your Ruolo table.

I’m not sure what the Chiave/Ruolo table is meant for, it appears to be duplicative.

Thanks for the reply!!

I want the choice of (Ruolo) to be made automatically and randomly.
Once a record enters in Username/Chiave table by filling out a form, a role (Ruolo) that is randomly chosen from the other table.
The third table is a table that contains the same role (Ruolo) chosen automatically but does not contain the username, it instead contains the username key.

Thanks in advance.

In that case you would need to set up an Automation that is triggered by form submissions, then runs a Script action with a script like the one below, and then an Update Record step that fills in the Ruolo field with the output from the script.

const table = base.getTable("Ruolo")
const query = await table.selectRecordsAsync({fields: []})
const records = query.records

const chosenOne = records[Math.floor(Math.random() * records.length)];
output.set("chosenOne", chosenOne.id)

That sounds like it should just be a View in your second table with the {username} column hidden.

Thank you for the help!

I don’t want to use the AUTOMATIONS, I am using the APPS. The script starts once the button is clicked!! So I need a script that lets me choose one of the Ruolo casually…
In the script written I have an error, tells me that the “set” is not a function!!!

What you’re asking for is contradictory. You first said you want the Ruolo to be selected automatically and randomly (and this post is under the Automations tag), now you want the Ruolo to be changed using the Scripting App (manual) and you want to choose the Ruolo.

Those are opposites.

output.set() is a function that only works in Automation Scripts, not the Scripting App. If you do want to run this through the app then you need to replace that line with one that updates the record.

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.