How to handle Single Select and Multi Select Options from Airtale scripting app

If you're facing errors while creating, updating, or deleting single-select or multi-select fields in your scripting app, don't worry! The reason behind these issues is treating these fields like regular text fields, when in fact, they require a different approach. Single-select fields allow users to pick only one option from a predefined list, while multi-select fields permit selecting multiple options. To avoid errors, ensure that you handle each field type properly in your script.

Let's consider a simple base example with a table containing expert data. This table contains information like the expert's name, gender, and skills. Name is a standard text field, gender is a single-select field and skill is a multi-select field. The table name is Experts.

First, we need a scripting app in airtable base. To install it, Go to extensions and then search 'scripting' and you will see an 'scripting app'. You can install it and open it.

Now that you have installed the scripting app, let's get tables and data into the scripting app. Then we will learn to populate the data. So, the Below code will get all the table's data and print it.


let table = base.getTable('Experts')
let data = await table.selectRecordsAsync({
fields:['Name','Gender','Skills']
})

console.log(data)

You can copy and paste the code and run it to see the output. The output will give you the records that you have in your table. Here in the above code, we are just getting the table and data and at last, we are printing it. Now let's learn how you can update the single select in Airtable. Consider the below code...


table.updateRecordAsync(
data.records[0],
{
'Gender': { 'name': 'Female' }
}
)

Now, the above code will update the single select field for the first record. The update process and structure remain the same but the structure of value changes if you have noticed. Here we don't just put the value of the field, instead, we put an object. This object contains a key as 'name' and a value as whatever the single select value can be. That will update the gender as 'Female' for the first record.

Isn't that simple? Now let's learn how you can handle multi select in Airtable through the scripting app.


table.updateRecordAsync(
data.records[0],
{
'Skills': [{ 'name': 'Python' }]
}
)

The above code will update the first record and in the multi-select field, it will become 'Python'. If you have noticed here, the structure for updating single-selects and multi-selects is not much different. The only difference is that you keep the value object in an array format. You can add multiple values in the array.

That's it. That was a simple procedure to update single and multi-select options through the scripting app in Airtable. If you still think it's complex, no worries, we can help you. Contact us for consulting, development, design, integration, etc... We provide all in one service that you can take advantage of when you use low-code or no-code software. Click here to book your free 15 Min consultation session

COPYRIGHT © 2022 · Monino Solutions ·