How to automate adding multiple rows from one table to a new table with a button?

Hi

I’ve been trying to add a set of tasks for a project to a new table. Based on all the values in the master table. We do this to add a default setup of each projects, with defined task and best practice in a notes field. Each time they plan on running that project it would be ideal for them to hit the corresponding button to populate their task list with the tasks for that project. Here’s an example of what I’m trying to do (with little success).

Do you have a suggestion of how to approach this one?

You could create a button on the project table that has a formula that looks something like this:
FormulaMap(
Lookup(Projects,Project,thisRow.Project),
AddRow(
TaskList,
task,
CurrentValue.Task,
notes,
CurrentValue.Notes
)
)

1 Like

Thanks Alex.

I tried to follow your suggestion, but I fear I have some issue following the formula syntax for now. I tried the following, but my coda newbiness gave me some issues.

FormulaMap(Lookup([Project Table],Project, Value),AddRow([Full Task List], Task, [Full Task List].Notes, Notes))

It complains about expecting 5 but finding only 4 arguments for AddRow. I’m also suspecting that the boldened code (real value= “thisRow.value” in this formula is not correct. I could not manage to find “thisRow.Project”.

Try:

[Project Table].Filter(Project = Value).FormulaMap(
  AddRow([Project Table], [Full Task List], Task, [Full Task List].Notes, Notes)
)

You need to indicate the table you want to add to. Otherwise very close!!

Btw, try to use Filter instead of Lookup if possible :slight_smile:

Thank you. I tried to change the formula, but there’s still no sign of it working. No errors this time though.

As to your suggestion I tried this formula.
[Project Table].Filter(Project=“Project 1”).FormulaMap(AddRow([Project Table], [Full Task List].Task,Task, [Full Task List].Task, Notes))

Is it the filtering part that is wrong? I tried to add a string value of one of the projects.

Here’s a link with comment rights for my doc and page if you want to see an up to date version. Test - National Tasks & Projects

Connor helped out on the shared doc. Thanks a bunch!

The formula ended up like this to achieve the wanted result:
It’s copying all the fields related to “Project 1” value of the Project table, over to the Full Task List table with the same columns.

[Project Table].Filter(Project=[Project 1]).FormulaMap(
  [Full Task List].AddRow( 
    [Full Task List].Project, Project, 
    [Full Task List].Task, Task, 
    [Full Task List].Notes, Notes
  )
)
4 Likes

One follow-up question for this function.

This works vert well when getting rows from a table that looks up the value of “Project” from another table as illustrated in this image:

When the Project column is change to a plain text field for the Projects, this no longer works. I can’t find the current value of Project, or selecting the actual value of “Project 1”. Just a string of “Project 1”

What’s the logic behind this? Do I have to have a predefined objekt? Like a tag, or a single lookup value from another table to make it work? Maybe @Connor_McCormick would know?

In addition I’m having an issue with “deleted reference” when trying to use this formula on a CrossDoc table. I’m not sure why, because the values are clearly in the table.

This livestream might be perfect for you!

1 Like

I finally figured out my problem. The synced crossdoc I used had a reference to another table, that was not available. I had to crossdoc that table as well before I could match any Projects from that table.

You can see the value, but you can’t act on any of it if it’s referenced through another table that is not synced. It kind of makes sense, but was not very obvious except for the message that it could not find the referenced data…

1 Like

Ooh! Add that feedback here! 😬 What was hard for you to discover in Coda? - #38 by Jean_Pierre_Traets

I am trying to replicate this formula but Coda seems to be automatically adding an Additional FormulaMap (overwriting my formula) and then it doesn’t work
I get (what Coda automarically adds in bold):

FormulaMap([Project Table].Filter(Project = Value).FormulaMap(
AddRow([Project Table], [Full Task List], Task, [Full Task List].Notes, Notes)
)
)

And I get ana error… What am I doing wrong here, I can’t crete buttons editingthe formula myself, I am forced to use one of Coda’s pre-defined templates?

Hey @Jean_Marc_Dieu ,
I can’t reproduce what you experience. If you (temporarily) share your doc with me I will take a look for you, or make a dummy doc resembling your doc and share it with me or the community. There’s probably a simple explanation for what is happening in your doc.

Greetings, Joost
(joostmineur@gmail.com)

Hi @joost_mineur
I figured out the problem… With some of the new formula interface in which Coda nudges you to use the formula wizard, it was overwiting my “hand-written” formula and generating the error.