Toggle item in multi-select lookup field with button

I’m trying to create a button that toggles the current row’s value in a multi-select Lookup field in a different table. See example below:

Clicking “RSVP” appends the teammate to the selected game’s RSVP list fine, but I want to have the button toggle, so that if the teammate is already RSVPed, clicking again will remove them from the RSVP list. I can’t seem to crack it.

Any suggestions?

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:

  CurrentAttendees,  //this returns a list a of rows in the Roster2 table, and can potentially be an empty 
  CurrentAttendees.Find(thisRow), // if thisRow the player is attending return his position in the list, 
// otherwise returns -1
      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


1 Like

Thanks for taking the time to answer, @Nad! I’d love to see your various approaches in action, but the embed looks to be private. Can you change the permissions?

Sorry about that, permissions changed so you can view and edit.

@Coda can we get a ListRemove() or similar to make this easier? This issue has come up several times for me, where I want to do an operation like [list] - [thisRow]

ListRemove() could be something like, ListRemove([the list], [the item to remove])

1 Like

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