Skip to main content
Solved

How to add New options to Multiple Select option


Hello,

I have three columns with multiple select options: Lecture (Mandatory), Lecture (Required), and Lecture (Optional). I want to automate the process so that if I add a new value to Lecture (Mandatory), it automatically gets added to the other two columns.

For example, if "English Lecture" is added manually to Lecture (Mandatory), then "English Lecture" should also be added to the multiple select options of Lecture (Required) and Lecture (Optional). 

How can i do that using automation 

I have make some small automation but it is not working

Set the Trigger:

Choose the trigger "When record matches conditions."
Set the condition to monitor the "Lecture (Mandatory)" field for updates.

 

 

 

 

 

 

 

let table = base.getTable("Your Table Name");
let recordId = input.config().recordId;

// Fetch the record that triggered the automation
let record = await table.selectRecordAsync(recordId);

// Retrieve the values from the multiple select fields
let certificatesM = record.getCellValue(" Lecture (Mandatory)") || [];
let certificatesR = record.getCellValue(" Lecture (Required)") || [];
let certificatesO = record.getCellValue(" Lecture (Optional)") || [];

// Convert multiple select field values to arrays of option names
let existingValuesR = certificatesR.map(option => option.name || '');
let existingValuesO = certificatesO.map(option => option.name || '');

// Convert the new values to an array of names
let newValuesM = certificatesM.map(option => option.name || '');

present
let updatedValuesR = [...new Set([...existingValuesR, ...newValuesM])];
let updatedValuesO = [...new Set([...existingValuesO, ...newValuesM])];

// Convert the updated values back to the format expected by Airtable
let formattedValuesR = updatedValuesR.map(name => ({ name }));
let formattedValuesO = updatedValuesO.map(name => ({ name }));

// Update the record with the new values
await table.updateRecordAsync(recordId, {
"Lecture (Required)": formattedValuesR,
"Lecture (Optional)": formattedValuesO
});

 

 

 

 

 


                                                    

Best answer by Sistema_Aotearo

Trigger:

Action 1: Update Record

Action 2: Update Record, Same thing but leave fields blank

 

View original
Did this topic help you find an answer to your question?

5 replies

If I'm understanding correctly, you looking for:

Trigger: When {Field A} updates.

Action: Update Record

  • Record ID: (From Triggering Record)
  • {Field B}: Field A
  • {Field C}: Field A

Shouldn't need a script for that. Unless I'm missing something. Let me know.


  • Author
  • Known Participant
  • 11 replies
  • August 2, 2024
Sistema_Aotearo wrote:

If I'm understanding correctly, you looking for:

Trigger: When {Field A} updates.

Action: Update Record

  • Record ID: (From Triggering Record)
  • {Field B}: Field A
  • {Field C}: Field A

Shouldn't need a script for that. Unless I'm missing something. Let me know.


@Sistema_Aotearo I don't want to update the Record. Should Updating Record is necessary? 

If I understand correct the update record place the same Value English Lecture to other two column?

I want to Update the multiple Select options. Currently I have the options in  Lecture (Mandatory), are "Python Lecture" , "C++ Lecture". But I don't have   "English Lecture" in multiple select option. 

 

 When "English Lecture" is added manually to Lecture (Mandatory) options, then "English Lecture" should also be added to the multiple select options of Lecture (Required) and Lecture (Optional). 

 


You want to add the option without making them selected.

I think the setup I mentioned does indeed add to the Multiselect options.

You can then just add an additional step to make those fields blank again. 🙂


  • Author
  • Known Participant
  • 11 replies
  • August 2, 2024
Sistema_Aotearo wrote:

You want to add the option without making them selected.

I think the setup I mentioned does indeed add to the Multiselect options.

You can then just add an additional step to make those fields blank again. 🙂


@Sistema_Aotearo  Can you please provide screenshot/picture for it. so that i can run it smoothly.


Trigger:

Action 1: Update Record

Action 2: Update Record, Same thing but leave fields blank

 


Reply