Help

Re: Remove an option from choice field when it has been selected 4 times

4065 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Mr_Hope
4 - Data Explorer
4 - Data Explorer

Dear community,

I have a field which gives a multiple choice of dates.
25fa77878eb85e87e4cf325bb28fafa555fba066.png

I would like to add an automation where when one of the options get selected for 4 times, it will be removed from the multiple choice list.

For example in the screenshot above, if 17/1 has been selected 4 times, remove or hide it so no one can select that anymore.
The idea behind it is that this is a registration form, and I offer 4 slots for each of those dates and when one of the dates has been selected 4 times the date slot should automatically be made unavailable.

To make that happen I could think there needs to be a few things

  1. A new field that counts the number of times the date has been selected
  2. Compare the field in 1) and trigger and action to hide the date slot but I can’t figure out how to hide the option from the multiple choice.

Hope I have explained well, thanks all!

4 Replies 4
Jonathan_Lutz
6 - Interface Innovator
6 - Interface Innovator

To the best of my knowledge removing an option of a single/multiple select field can only be accomplished via scripting. As is the case with scripting in Airtable, the script can be in the form of a Scripting app to be triggered manually or a step in an automation, the latter of which seems to fit the bill here.

The script to do so looks something like the below. Take note of the enableSelectFieldChoiceDeletion option which allows for previously available options that don’t exist in the choices array to be removed:

let table = base.getTable('Table Name');
let selectField = table.getField('Field Name');
await selectField.updateOptionsAsync(
    { choices: [...selectField.options.choices.filter(c => c.name != 'Option 1')] },
    { enableSelectFieldChoiceDeletion: true }
);

The caveat here, however, is that removing an option from a select field doesn’t just remove it as a selection for new records. It also removes it as an option from existing records, so any record that had that option as selected previously would now have an empty value in the field.

One way to work around that is to create a separate select field with the same values as the original, & copy the value to that select field prior to removing the option from the user-facing field. That way you’ll be able to keep the selected value for all records, even if they have since been removed due to being selected x number of times.

Hope this helps!

@Mr_Hope Note that you can do what you want automatically with a linked record field, but not with a multi-select field. If you want/need to stick with a multi-select field, you’ll need to manually craft your own workaround like the ideas that @Jonathan_Lutz outlined above.

Hi Scott! I’m trying to follow your approach of using a linked table so that I can remove records as selection options from a field when said records have already been selected. However, even though ‘Allow linking to multiple records’ is turned off in both linked fields, it’s still possible to select the previously selected options for new records even though they are not supposed to be selectable anymore.

What are the steps to follow so that previously selected options are no longer available for future selection in a linked field?

You could limit selection to a view, and make that view filtered to only show you options which haven’t been selected yet. I show off that technique in this week’s BuiltOnAir video podcast: