Relate contacts and addresses in Coda
Get always the most recent address
We all know that address and contact information changes over time. To keep track of these changes we can overwrite an old address with a new address or we can add the new address, time stamp it (as we did with the old address) and filter on the most recent one. In this blog you see how you can set up your own logic to get the most recent address first.
Keeping track of addresses
We have a table that generates addresses. In this table we have a linked relation towards contacts. This means that an address can be linked to multiple people. We can do that in two ways. First, we have a button opening a modal to create an address and from there we add people to the address. The second route starts in the modal of the contact table. Whatever the route we take, each address gets a timestamp.
Example
Recently I moved. Previously I lived somewhere else, luckily for me — also in New York. The Bricetown road address was created sept 27. Today we are early november and we need the november address.
To get the november address we filter on the most recent address.
The logical rule
In this table of contacts in which the actual state of affairs is important we compare the fromDate with the date output from the function Today()
. The result can be a list of dates and from that list, we take the last. Try it for yourself and you see how easy the set up is as long as you deal with one variable (most recent address) . I advice you to set up your own tables and test this logic. Once you have the feeling, you will use it over and over again.
Something else, in the screenshots you see the function Today()
, but you can also use Now()
or any other output to get the correct result. More about this logic in my blog related to products and prices.
Relate addresses to contacts
An other entry of addresses passes via the contacts. We create a person and we offer the option to link it to an existing address. Once the address is selected, we modify the row in the address table and add this person to the people. When the address is blank we do something else. Whatever we do, we always return to this contact table. That is why you will see as closing command the function thisTable.ObjectLink().OpenWindow()
.
Already an address
All this code is wrapped in a SwitchIf().
It became one of my favorite functions due to two powers: multiple checks on true permitting for hierarchy and no need for a fall back option. You can say, if this then that. A simplicity I can appreciate.
We check if the address select column is not empty, or in Coda terms IsNotBlank().
In that scenario we look for the address in in the table DB Addresses and we name the outcome root.
Next we modify only the row that is equal to the outcome of the previous filter by adding root. That explains the root.ModifyRows()
. To avoid that all rows get updated we apply two logics. First we find the proper row using root
again in root.contacts
. Second the ListCombine()
permits us to add the new contact (living as object in thisRow) to the already present contacts.
No address yet
We continue with the case that there is not yet an address related to the contact. We get nothing back when we filter on address and when that happens we add a row and we prefill the contact in the table DB Addresses with the contact living on thisRow. To avoid confusion we we open the modal of the table DB Address in full screen. It is in this screen the user can add the contact details.
This is altogether not very difficult, but it takes some time to figure out.
Conclusion
By adding a timestamp to an address, you can filter on the most recent. Addresses can have multiple contacts and when somebody moves, you create a new address and you link the people to the new address. We linked the contacts to addresses in our set up to make it easier to have people and places connected.
This blog is part of small serie of 3 blogs in which I show the advantages of a BOM approach related to:
- addresses (this one)
- product prices
- contact details.
My name is Christiaan and blog about Coda. Since the summer of 2023 mainly about how to Coda with AI to support organisations dealing with texts and templates. Why I focus on Coda AI you can read here: ⤵️
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. You find my (for free) contributions to the Coda Community and on Twitter.
Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).
Not to forget: the Coda Community provides great insights for free once you add a sample doc.