How to Coda a guest list?
Checking for and adding when necessary
You have a list of people you expect and you are open add a few more. You check if a name is on the list and if so you confirm the presence and if not you add relevant details.
The process is rather easy. You have your Coda app open (as a doc on your desktop or on your mobile). You type the name of the person and if there is a match, you confirm. If not, you add the person to the list.
The main elements in this blog are:
- filter on the name
- confirm the presence in case of a match
- open a modal to fill out details
- close the modal
Filter on the name
Filtering on the name goes via a controller; the type of filter inherently part of the table view. You only see what matches. To get a match we use a column containing the full name (thus first name and last name put together). The function
Lower() is applied to flatten out capitals and the function
Find() to check if the string appears in the column. Details on the Find function in this blog. All we need to remember is that in case the position is greater than 0 (>0) the name (partly) exists. The name(s) that fit the search appear and you keep on typing until one full name is left.
Confirm a match
Once you have a possible match (the find functions outputs a value greater than 1) you should be able to check this guest so it leaves the list of attendees yet to come.
The formula logic to indicate the match is not complicated, see below.
The visual trick is to create a canvas formula that shows results and when nothing is found or when the search box is empty, the formula results in a close to invisible light grey box, see below:
However, we have to take the logic one step further to make it possible to confirm the presence. We solve the issue by using the same button to confirm the guest and to — if necessary — add a new guest to the list. This goes in two steps:
First, we check if there is only one name and if so we start filtering on this name and we use
ModifyRows() as you see below.
The If statement also tells us what to do if there is no match. Please note that the user has to make sure that only one name comes up. Later on in the process, we’ll solve possible human errors by deleting rows that do not contain a first or last name. Below the code to avoid incomplete records.
[DB GuestList].Filter(Firstname.IsBlank() or Lastname.IsBlank()).Formulamap(DeleteRows(CurrentValue))
So far we have the solution to check a guest. Next we show how to add a guest in case we have no match.
Add a new guest
Adding a new quest requires we fill out a form or something that looks like a form. Here we use the full screen option and we trigger this option under certain conditions. First we add the name to the column Firstname and second we open the row that contains this first name.
The action is that we push the button ‘Full View’. This button opens the row with a simple line of code:
The result is what you see below with the first name already filled out. Once completed, you click to confirm. I did not set any field as required in this example and I added an image as footer to cheer up the page.
In case you have here and do not fill out the first or last name, in a next session this row is deleted.
Once done you confirm and the idea is that the user goes back to the screen to continue with the next quest. For this we need to open this page. In other cases, you simply want to see the table you have been working on. Below the logic when you want to return to the table you started with.
Here the logic to return to the source page. The tricky thing in this set-up is that I used the URL of the page.
One you have more pages like this in your doc, you might consider to set up a table and link to values in this table using the ‘@’ logic. This use case does not require such an approach.
Extra — limited roles
So far many readers — given some time and a bit of trial & error — will be able to set-up this kind of logic. This extra item requires a deeper understanding of how to Coda. It links back to my blog post “Coding Look-Ups in Coda as a Pro”.
The question is if we can only show guest roles when they are still available? This implies we have to set a filter value in the lookup.
We created a a table that contais the max amount of certain roles and leaves the guest role open because there is no direct limit set for guest roles.
We first start counting to see what we have. In the example we are allowed to have max 4 instructors, 3 cooks and as many guests as possible (unless we top off the totals by let’s say 100 people). We start simple and create a helper column the the table DB Guestroles in which we store the actual count per role (instructor, cook or guest). We compare the items in the filter and off we go like below:
currentValue.max.IfBlank(100000000) > CurrentValue.HLPR_max
By adding a big number, it always works for guests. As mentioned in other blogs, the filter here concerns the ‘inside’ of a standard filter. We look for something true. We chain values (currentvalue.max and currentvalue.HLPR_max) to access the values in the source table.
Limit the group size
It was on purpose I left the value open for guests. I wanted to be able to indicate a max size. Let’s assume 100, the table will look like below:
The formula we need you find below. We replaced the
IfBlank() with the max amount of guests and we add the condition that we cannot have more table rows than this max amount of guests (one row per guest). The canvas formula is used to keep track of the rows in the table.
But of course we can still add rows! The above shown trick only stops you from attributing a role. To disable the option to add more rows than permitted, we add a disable condition in the main button for obvious reasons.
This blog was about using buttons and a lookup to keep track of guests. Although I try to present the logic as simple as possible, be assured that I also make mistakes while building and sometimes wonder why the logic I had in mind does not work (properly). This is part of the game. You understand the building blocks, but putting the pieces together takes some effort.
It is because of this that I decided to add a doc to this blog posts that contains the formulas and thus the action. It is the first doc of this type for sale (19 Euro) and I plan to bring out at least one a month, but probably more as I will rework some of my older blogs and add docs to it. The moment I see room for improvement in any of these docs, I’ll adapt. These changes will not always be described in the blog post.
In the related doc I also added the option to put people on a spare list, but did not describe this process in this doc.
If you want to speed up your learning process, you pay 99 Euro per year or you pay per doc (19, 29, 39 , 49 Euro or more). Followers (certainly the early birds) will enjoy the full package for 99 per year. As time goes on, I’ll probably rework the model, add video, etc. But first things first, we start with the doc:
I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter