Stuck with duplicating all rows from one table into another table

Hello community! I’m working on a project for onboarding new employees and I’m stuck with a formula. Basically I’m trying to duplicate rows from a template table into a master table with the addition of their name so I can filter by logged in user to show only their tasks.

What I’m trying to do in the sample doc below:

  • The Tasks Template table holds the tasks I would like to duplicate
  • Those tasks should go into the My Tasks table at the push of a button
  • The button is labeled as Run Actions in the New Employee Info table
  • The new rows in My Tasks should also have the Employee column filled in with the Coda Name from the New Employee Info table so I can filter them by logged in user

I added a formula in the Run Actions button that will add all the correct info from the rows, but it goes into one row instead of multiple, and I can’t seem to get ForEach() in the right place. Thank you for any help you can offer!

Here’s my sample doc:

Hi Heather,

Here’s one solution for you using the ForEach formula to loop through each task.

  [Tasks Template].Task.ForEach(
     [My Tasks].AddRow([My Tasks].Task,CurrentValue,[My Tasks].Employee,[New Employee Info].[Coda Name])

Let me know if you would like me to update the formula directly in your doc.

You can also use ForEach for the whole table. Then the formula will be updated to

  [Tasks Template].ForEach(
     [My Tasks].AddRow([My Tasks].Task,CurrentValue.Task,[My Tasks].Employee,[New Employee Info].[Coda Name])

Using CurrentValue.Task as the value for the Task column.

1 Like

Thank you so much, @boonshin! This worked perfectly.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.