Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here
Nov 18, 2022 07:08 AM
Hi!
Airtable newbie here. I’m using a Linked Record Field in a Form.
If someone submits the form with having more than 3 linked records/items selected, I would only like to have 3 records/items (max) only recorded in my table.
Any help is appreciated.
Thanks
Nov 20, 2022 02:35 PM
Create an Automation that monitors change within the Linked Field, then you’ll need to run a script that’s similar to this;
In this example, the linked field is a “Tags” table, that the main “Products” table links to - which is from a previous example I gave in another thread.
//Get the record with the "Tag" field change
const inputConfig = input.config();
const productsTable = base.getTable("Products");
const myRecord = await productsTable.selectRecordAsync(inputConfig.recordId);
if (myRecord.getCellValue("Tags").length >= 4) {
let lastThreeRecords = myRecord.getCellValue("Tags").slice(myRecord.getCellValue("Tags").length-3, myRecord.getCellValue("Tags").length);
await productsTable.updateRecordAsync(inputConfig.recordId, {
"Tags" : lastThreeRecords
})
};