Skip to main content

I'm a javascript developer, but all the examples I can come across are either too nuanced or specific for my needs, so I'm hoping to find a simple script to take the following table which has a column of linked records from a third table:

Table_1

IDLinked
1A,B
2B,C,D

And spit out the following table:

Table_2

IDEach_Link
1A
1B
2B
2C
2D

Thanks!

Here's something that should do what you're looking for, and the code is below

let table = base.getTable('Table 1')
let record = await input.recordAsync('Pick a record', table);
let linkField = "Table 3"
let idField = "ID"

let tableToUpdate = base.getTable("Table 2")
let tableToUpdate_idField = "ID"
let tableToUpdate_eachLinkField = "Each_Link"

let linkedRecords = record.getCellValue(linkField)

let updates = new Array

for (let r of linkedRecords){
updates.push({
fields:{
[tableToUpdate_idField]: record.getCellValue(idField),
[tableToUpdate_eachLinkField]: r.name
}
})
}

while (updates.length > 0) {
await tableToUpdate.createRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}

 


Perfect! Thanks. Clear and simple.


Reply