Help

Using a form to remove a multiple-select option from a record

6325 14
cancel
Showing results for 
Search instead for 
Did you mean: 
Stu_Smith
6 - Interface Innovator
6 - Interface Innovator

I have a fairly complex set-up with Airtable automation and Integromat automation that does a whole bunch of stuff very nicely. I'll attempt a simple description of one part of it that is relevant to my request...

People can use a form to "watch" for changes in a record. Their email address is added as a multiple-select option to that record when they submit the form. The automation I've set up sends them an email when that record changes.

This all works fine but now I want to allow them to cancel this alert and I'm a bit stumped. My thinking is that they can use a second form which references the record and their email address and when it's submitted the automation will look up the record and remove the multiple-select option that matches the email address if it exists.

I just don't know how to do this. I'm assuming a script will be required and I'm not familiar with scripting myself.

Help? 😅

14 Replies 14

Hi @Stu_Smith !

If you are already using Integromat, would something like this work for you?

Greg_F_0-1670125253243.png

Use some trigger like e.g. webhook to trigger search for the reference record and use `remove` function in next step to take out the email from the array of Multiselect.

If you would like to do it with code. You could use the filter function to remove that one multiselect option that is equal to email that needs to be removed.

Let me know if that helps!

here is the code, apologies for plain text - it looks like the new community is not allowing me to embed code block (even from the toolbar...)

let table = base.getTable("Rooms");
let field = table.getField("Multiselect");
let emailToRemove = "email1"
let recordToUpdate ="recsjobMMpxlE7saG"

// Load all of the records in the table
let result = await table.selectRecordsAsync({fields: [field]});

let record = result.getRecord(recordToUpdate)
let updadatedRecord = await table.updateRecordAsync(recordToUpdate,{
"Multiselect": record.getCellValue("Multiselect").filter(option=>option.name!==emailToRemove)
})

Thanks! I've tried to implement this, swapping out some of the variables to match mine but I'm getting the error that it can't find the record. Record ID is correct so I think I've gone wrong at the first line... what should be where you have "Rooms"?

I tested it on a datase I was using, so in my case the table name was "Rooms". "Multiselect" is a name of column that is of a multiselect type and it has multiple emails as options.

The recordToUpdate is the ID of the record, from which one of the emails is supposed to be removed.

Let me know if this is making sense?

Stu_Smith
6 - Interface Innovator
6 - Interface Innovator

Yup. Makes sense. So I've changed it to the following using the table ID, column name from that table, and the two variable pulled from the form (see screengrab). The script input values are correct for the record ID and email address. I get this error: "Error: No record matching "product_record" found in query
at main on line 9"

let table = base.getTable("tbl8991KzXJJ7prHz");
let field = table.getField("Watchers");
let emailToRemove = "email1"
let recordToUpdate ="product_record"

// Load all of the records in the table
let result = await table.selectRecordsAsync({fields: [field]});

let record = result.getRecord(recordToUpdate)
let updadatedRecord = await table.updateRecordAsync(recordToUpdate,{
"Watchers": record.getCellValue("Watchers").filter(option=>option.name!==emailToRemove)
})
Screenshot 2022-12-04 at 10.34.33.png
Stu_Smith
6 - Interface Innovator
6 - Interface Innovator

Screenshot 2022-12-04 at 10.34.33.png

Stu_Smith
6 - Interface Innovator
6 - Interface Innovator

Screenshot 2022-12-04 at 10.38.10.png

OK I see it now!

Delete this part:

Greg_F_0-1670147299299.png

And replace it with

const { product_record, email1 } = input.config()

let emailToRemove = email1
let recordToUpdate = product_record