Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: Casually Value from 2 differents tables

2102 1
cancel
Showing results for 
Search instead for 
Did you mean: 
diaanehme
5 - Automation Enthusiast
5 - Automation Enthusiast

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?

Sc0

Sc1

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

Sc2

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

5 Replies 5

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.