Actioning on items in list 2 for each list 1 item

Hi there! I’ve tried looking up on the forums but I’ve been unable to find an answer. Here it goes!

I would like to create an archiving mechanism. Given that I have rowIDs in Completed Projects table and rowIDs in table B, for every rowID in list A, find the matching rowID in list B and copy the entire row to a new table.

What I was thinking was creating a button to loop through list A via forEach and then filtering list B by currentValue. Kind of like

CompletedProjects.forEach(
   ListB.filter(ListB.[rowID]=CurrentValue.[rowID]).RunActions...)

but the currentValue isn’t populating correctly. It’s taking in the listB table instead of the completedProjects table. Does anyone know why this is?

Here is the sample page. You might need to request permission to access since it’s on a Coda Org.

Hi @mattics ,

It seems you didn’t really publish the doc, but anyway, the problem seems to be the CurrentValue. You think it is referencing CompletedProjects, but it actually references ListB. You need to use WithName() in order to save the CurrentValue() from the forEach() and use it within the filter()

CompletedProjects.forEach(
  CurrentValue.withname(CurrentProject,
    ListB.filter(ListB.[rowID]=CurrentProject.[rowID]).RunActions(
      [...]
    )
  )
)

Hope this helps,

Pablo

1 Like

Nice, thank you @Pablo_DV ! Interesting function, withName. It’s pretty much creating local variables. Is my thinking correct?

Yeah, but not for the whole formula, only for the code between the brackets.

1 Like

Nice, thank you :). Didn’t know about withname. Definitely going in my toolbelt!

1 Like

Just as reference. I prefer the Let() formula. It does the same thing as WithName(), but it is smaller.

2 Likes

Ahhh, “let” nomenclature makes more sense. Thank you! Just like how I prefer foreach instead of formula map :stuck_out_tongue:

1 Like

I’m still set on the old ways :sweat_smile:

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