How do I create an archive button that will move all the rows in a table with status="done" to another table?

Hi @Paul_Camacho :blush: and Welcome to the Community :tada: :grin: !

It is completely feasible by using a formula looking like this in the Action of your button :
(See the quick sample doc below :wink: )

Bugs.Filter([Bug Status]=Done).FormulaMap(
  RunActions(
    AddRow(
      [Archived Bugs],
      [Archived Bugs].Bugs,CurrentValue.Bugs
    ),
    DeleteRows(CurrentValue)
  )
)

What it does is :

Step 1: Filter the table Bugs to find the rows where the bug has been marked as Done, which is returned as a list of rows :blush:

Bugs.Filter([Bug Status]=Done)

Step 2 : For each (FormulaMap()) items in the list (i.e.: the list of the previously filtered rows where the [Bug Status]=Done. Each specific Bug in that list being represented by CurrentValue (more precisely: each specific Bug is stored in CurrentValue)) run those actions (RunActions()) :

  1. Add a row in the table [Archived Bugs] and in the field [Archived Bugs].Bugs put this very specific bug CurrentValue.Bugs from the list of all [Bug Status]=Done
AddRow(
      [Archived Bugs],
      [Archived Bugs].Bugs,CurrentValue.Bugs
    )

Then

  1. Delete all the rows where [Bug Status]=Done
DeleteRows(CurrentValue)

To illustrate, here’s the sample :blush:

As I personally know (:sweat_smile:) FormulaMap() isn’t the most easiest function to grasp, here’s a post that might help/interest you :blush:

Now, depending on your setup and the future of your doc, in terms of performance, this could become a problem on the long run as each time you’ll click on that button, the button will need to go through the whole table to pin-point the appropriate rows to move…

If you intend to keep this table small, clean and tidy, with very very few rows it should work just fine but if you envision a Bugs table with hundreds of rows this button might get a bit slow :innocent: .

What I could suggest you here is to use a filtered connected view of your Bugs table instead of moving rows from one table to another.

The main/master table would be the Bugs one, in which the [Bug Status]=Done are filtered out (either by using an Interactive filter or a more classical one in the table’s options. In the sample below, I used an Interactive filter on that table)

The view would be your Archived bugs in which any status that is not Done is filtered out :blush: .
(In my sample, I chose a “classical” filter in the table’s options)

Another potential option (generally the best solution so far, still in terms of long term performances) would be to use Cross-doc :blush:

Hope this helps :blush: !

2 Likes