How to flatten a list of lists?

Good afternoon, Everyone:

I created an Address Book app. Each Contact can have multiple Email Addresses. In the Contact Details table, I created a VC called Related Contact Email Addresses By ContactID of type List. AppSheet graciously populates that field as Email Address records are added and associated with a Contact.

Things were moving smoothly until I saw that Email Address records became orphaned whenever I deleted a Contact without first deleting Email Addresses. Granted, orphaned records don’t negatively impact the app’s operation, but I find it distasteful from an esoteric point of view :grinning:

My current solution works, but it is not efficient. I created an Action called Delete All Email Address Records referenced by Contact Detail Record. Here is a screenshot:

I’m unsure how AppSheet executes the SELECT, but the worst case scenario is that it is a linear, brute force search. That will slow down as more Contacts and Email Addresses are added.

Well, then I thought why can’t I leverage the existing “Related Contact Email Addresses By ContactID” in the Contact Details table? All of the EmailAddressID’s are right there, courtesy of AppSheet. So, I changed the Action to this:

However, I receive an error saying, in effect, that the result of the SELECT is not a list. It won’t tell me what it returns, but I suspect that it is a List of Lists.

Is there a way to flatten it?

Thank you,

For Referenced Rows, try just:

[Related Contact Email Addresses By ContactID]
1 Like


Amazing! How simple was that!


1 Like