Aug 18, 2020 04:16 PM
I have two fields that use the Collaborator field in a table (Lead & Support). In order to do some filtering, I need to have a field that concatenates both collaborator fields but Airtable doesn’t want to let me. Any workaround?
Thanks!
Aug 21, 2020 09:36 AM
How are you doing the concatenation? This works for me:
Collab1 & ' - ' & Collab2
Aug 21, 2020 09:55 AM
Thanks Jonathan, what I need to do for filtering purposes is have the result as Collaborators, not just text. Any way?
Aug 21, 2020 10:21 AM
OK, I understand. It could be done with a script. Or it could be done with the new Automations feature. Try this:
Note the comma between the two ID values (it won’t work without this)
So, when the lead and support collabs have been added, the record enters the view, the automation runs and it populates the multi-collab field with both.
Aug 21, 2020 12:57 PM
Thanks again, Jonathan. This looks promising but I am not familiar with the new automations. I tried to follow your example.
When I get to the “fields” area,
If I did it correctly, could the problem be that both of my collab fields are also multi-select? If not, what could be causing the fields to be unavailable?
I really appreciate your help.
Aug 21, 2020 01:08 PM
In addition to the above, I have two questions:
Aug 21, 2020 11:35 PM
Hi @Brite_Admin, OK maybe this approach won’t work. I assumed that your support and lead fields are “single” collaborators. You’re right that if the field is a multi collaborator you can’t select it in the automation. This approach also won’t work if you add an additional collab to one of the fields later as our definition of the view wouldn’t be re-triggered (although potentially, there could be a different view that does re-trigger).
As an aside, the view was based on:
Collab1 is NOT empty AND Collab2 is NOT empty
i.e. they both have an entry so are ready to be concatenated into the multi field.
At this point, I’d be looking at a script to do the work for you. Something like this will do the trick:
let table = base.getTable('Table 1');
let query = await table.selectRecordsAsync();
for (let record of query.records) {
let collabs = [];
if (record.getCellValue('collab1')) {
for (let collab1 of record.getCellValue('collab1')) {
collabs.push({id:collab1.id})
}
}
if (record.getCellValue('collab2')) {
for (let collab2 of record.getCellValue('collab2')) {
collabs.push({id:collab2.id})
}
}
// remove duplicate users
let uniqueCollabs = Array.from(new Set(collabs.map(a => a.id)))
.map(id => {
return collabs.find(a => a.id === id)
}
)
let allCollabs = await table.updateRecordAsync(record, {
"All collaborators": uniqueCollabs
})
}
based on this table:
The script elements in red would need to be modified to match your table and field names. Note that each time you run it it runs for the whole table and replaces the “All collaborators” value with a new value (the two collab fields mashed together).
Try it out on a copy of your base first :slightly_smiling_face: