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
May 18, 2021 09:58 AM
I’m working on a new personnel base and I’m having trouble wrapping my head around how to execute a link I’d like to see. Here’s the scenario:
I have 1 table of Staff. They are numbered based on the order I would like to hire them to work an event. So, if I need 5 people at an event, the staff numbered 1, 2, 3, 4, and 5 will be called in for the event. If I only need 2 people for the next event, it will still be staff #1 and 2.
I have another table of Events. Here I put in the number of staff I need, and I would really like to build a way for it to auto pull and link the appropriate staff members.
Any ideas?!
May 18, 2021 12:05 PM
This would need an Automation that includes a script. You should try something like the following:
Automation Steps
Run a script
key: count, value: the trigger record's {Necessary Staff Count} field
Script:
let {count} = input.config()
let table = base.getTable("Staff")
let query = await table.selectRecordsAsync({
sorts: [
{field: "Staffing Priority"},
]
})
let records = query.records.filter(record => Number(record.getCellValue("Staffing Priority")) <= count)
let recordIDs = records.length > 0 ? records.map(record => record.id) : []
output.set(recordIDs , recordIDs)
Update record
Events
record ID from trigger
{Staff}
= output from the Run script action