Auto populate relation column with formula

I have imported 2 relation tables into Coda, Contacts and Companies table. The relation of these 2 table is based on the column [Contact ID (FS)] which exists in both the tables.

But when I imported the tables into Coda and add a relation column in the Companies table, I will need to manually select the corresponding Contacts rows for all the rows in the Companies table.

I do not wish to change the default relation column formula since it will be used for new entries made in Coda.

I tried to use a formula button in a page to do this instead but the code provided by CodaBot AI support has errors.

FormulaMap(Companies, company =>
ModifyRows(Companies, company, [
Contacts: Contacts.Filter(contact =>
contact.[Contact ID (FS)] = company.[Contact ID (FS)]
)
]) // errors starts here
)

Need help on the formula. Thanks!

hi,
no need to :
company =>
contact =>

coda formulas are not exactly javascript.

adapted but here is an example. Without the full context difficult.

Companies.forEach(
   let(company, currentValue,  
      ModifyRows(company, Contacts, DB_Contact.filter(currentValue.ID == company.ID))
   )
)
1 Like

You’ve given me an idea to explore. I need to copy a large spreadsheet once a week to Coda. There are some columns that would be nice as select lists, but Coda does not link to the existing select list entries.

Maybe this will help.

Thanks for the reply.

I have managed to solve it with the help from Coda Support Team as well as the CodaBot AI. This time, the AI managed to give the correct formula.

The Support Team suggested using button column and push button. The push button is used to activate all the button column.

Formula used in the button column in the Companies table.

The formula will update the relation column [Contacts] in the Companies table when the column [Contact ID (FS)] in the Contacts table is equal to the column [Contact ID (FS)] in the Companies table.

Then add a push button on the page to activate the button column (no screenshot).

Breaking down the function in this way will allow you to have a simpler formula.

Thanks.