Toggle item in multi-select lookup field with button

hi Abby and welcome to the Coda community !

There is more than one way to do this, and it depends on how committed you are to your current table structure and set up.

The solution you asked for:

This is illustrated in the page RSVP2 of the embed below and tries to stick to exactly your current setup

  • You first should append .first() to your NextGameRow formula. When you filter a table, the result is a list of rows, even if that list of rows only contains one row as in your case. Adding .first() extracts just the first row, which probably what you had in mind. It makes working with this named formula downstream much easier.

  • Here’s a breakdown of the formula used in the button:

WithName( 
  nextGameRow2.RSVPs,
  CurrentAttendees,  //this returns a list a of rows in the Roster2 table, and can potentially be an empty 
WithName(
  CurrentAttendees.Find(thisRow), // if thisRow the player is attending return his position in the list, 
// otherwise returns -1
  IsAttending,
  nextGameRow2.ModifyRows(
    Games2.RSVPs,
    if(
      IsAttending>0, // this player is in the rsvp list
       CurrentAttendees.Splice(IsAttending,1), // a copy of the rsvp list with the player removed 
       CurrentAttendees.ListCombine(thisRow) // a copy of the rsvp list extended to include the player
    )
  ) 
)
)

If you find this formula a bit too convoluted, and are willing to reconsider your structure, I recommend you consider:

The Solution you probably need, assuming your doc is not shared with your players:

This is illustrated in page RSVP3 of the embedded doc.

I added an RSVPs Table, and a select column in the Roster table allowing to choose which game to toggle the RSVP to. The button then only deals with added or removing an RSVP row.
Benefits of this are:

  • Much simpler formulas
  • The same doc can be used for RSVPing to multiple games concurrently
  • You keep a track record of when the RSVPs where submitted. You could imagine extending the RSVP table to add notes by the players etc.

The simplest solution you probably need:

if 1) your doc is shared with your players and 2) you’re willing to juggle a bit your structure, then the most elegant and simple solution is already provided out of the box by Coda and does not require any formulas:
Simply add a Reaction Column in your games table and call it ‘RSVP’ and choose an appropriate icon. Each player can RSVP by simple clicking the button.

I didn’t illustrate this in the embedded doc, because I assume you have a good reason to keep your players out of this doc, but do let me know if you want to see what it would look like

Nad

1 Like