Nested List from two columns in Airtable

Hello,

Wondering if anyone can help me with creating a nested list from two columns of data in Airtable.

Here are the columns and structure I’m going for:


Workflow 1
Feature 1
Feature 2
Feature 3

Workflow 2
Feature 4
Feature 5
Feature 6

etc

Here are the app variables:

And composer views:



Getting a totally blank screen in preview.

Can’t find what I’m missing. Thanks for having a look!

I fixed some errors in the previous post, but am still getting a blank preview for some reason. Updated structure per this example: Nested List, Flexible Depth



image

I’d suggest you use debugger to take a look at your actual runtime data. Or you could also render a paragraph with ENCODE_JSON(appVars.workflow) etc. to view it.

Thank you.

I think the issue is that the objects in my Airtable API response only contain strings instead of another array of objects. I’ve tried all different types of field types in Airtable but can’t seem to get Objects.

Is there a way to convert those strings to objects in Composer?

This is valid JSON and as far as I know the Composer should parse this as array of objects when requested.

In that case I have no clue what’s wrong. When I try to repeat the List item in the nested repeat, the types of fields I’ve tried in Airtable (Workflow, Workflow1, WorkflowLookup) are all incompatible.

App ID: 120704

image

I did notice that an “Attachment” field in Airtable auto-generates a List of Objects in the Schema that is compatible with the nested repeat, but that doesn’t really help here.
image

Any other suggestions?

The thing you’re repeating should be an array of objects [ {}, {}, {}, {} ] with all the objects having same schema. So in this case I guess you would want to repeat array of “fields” objects.

You can always try to repeat something if you use a formula to bind it straight, ignoring the incompatibility warnings.

I can’t get this to work with an Airtable schema for the life of me. It works perfectly with the RestCountries data collection. Any chance you could show how it’s done with a simple dummy Airtable dataset?

I was able to hack it a bit by using the SELECT function in dropdown fields. Not ideal though.
image

image image

Preview:
image

Thanks!

This sounds more like a bug. I’m just gonna ping @Kimmo to take a look at this and figure out what’s wrong.

Could you show the data that’s coming through the request at your airtable? You can see it in your browser inspector network tab when testing in rest configurator or during runtime. Just to figure out how the schema is not working when repeating.

About the repeats: Composer Pro does not unfortunately yet support repeating list of texts directly (showing them “incompatible” if attempting to repeat), but you can instead use formulas to convert a list of strings to a list of objects!

So if you use this kind of formula in “Repeat with”:

MAP(current.SomeListOfTexts, { value: item })

And name it e.g. nestedCurrent then you should be able to use the text from the original list by using repeated.nestedCurrent.value

Thank you Sasu and Kimmo!

The MAP function worked nicely on my list item. Now I’m trying to use the UNIQUE_BY_KEY function on the Title so the list only displays each item once. Assuming the same string vs. object conversion would apply here, but I’m stuck again.

This is what I get without trying to remove duplicates:

And this is where I have issues:

Repeated Container with the collection data variable:
image

And then in the Title, tried to MAP again and filter out duplicates with UNIQUE_BY_KEY (“Workflow1” is a List of Texts in the schema):

List Item looks like this:

Which results in this:

Thanks for sticking with me on this one.

Shawn

You were right that UNIQUE_BY_KEY would help you in this case! However, you don’t need to use that in the Title component’s Content.

Instead, you should use this function in the related “Repeat with”. So you need to use a formula for the repeat that you’d like to make duplicate-free.

So the question is what repeat you’d like to make duplicate-free? The “Container 2” or the “List item 2” repeated inside each container?

Whatever it is, the formula would look something like this:

UNIQUE_BY_KEY(thingsToRepeat, "someIdentifyingPropertyName")

So for example, to repeat “feature” objects in a data variable but leaving out objects that have duplicate name property (just my guess, you should change this according to your schema), then the formula could look like this:

UNIQUE_BY_KEY(data.AllFeatures, "name")

Or if you want remove duplicates from the inner list items:

UNIQUE_BY_KEY(MAP(current.fields.FeatureLookup, {value: item}), "value")

Thank you! Man this is so close–The “Workflow” duplicates removed nicely with UNIQUE_BY_KEY, but now I’m just having trouble repeating the nested the List Item (“Features”) under the repeated Container (“Workflow”).

I’m trying to get the nest list to look like this:

Workflow 1
Feature 1
Feature 2
Feature 3

Workflow 2
Feature 4
Feature 5

etc, etc…

So I repeated the Container so each “Workflow” would show in the Title. And also mapped a “value 2” to get the “Feature” field to show up in the List Item:

UNIQUE_BY_KEY(MAP(data.AllFeatures, {value: item.fields.Workflow, value2: item.fields.Feature}), "value")

Then bound “value” to the Title content:

But then how do I nest the “Features” under the “Workflow” in the List Item? I’m not sure what to repeat there.

Thanks again :raised_hands:

So this is a case of a nested repeat which you already determined yourself!

So I assume here that the item.fields.Feature that you made available in value2 is a list of strings. In this case you can set “Repeat as” of the “List item 2” to the following formula:

MAP(repeated.currentWorkflow.value2, { value: item })

(As a side note: you only need to a formula with MAP if this is a list of strings. If this is a list of objects, you can even bind the “Repeat as” directly to “currentWorkflow” -> “value2”)

This formula above means that you repeat the list item for each feature of the currently repeated workflow!

You can set “Repeat as” to, for example, currentFeature

After this, you should be able to bind “Primary label” to “Property of data item in repeat” -> “currentFeature” -> “value”

That MAP function worked for the List 2 repeat, but it’s still only showing one Feature for each Workflow in the preview.

The Airtable schema is tricky–only way I could get a column to be a list of strings is to make it a Lookup column instead of regular text.


So I used this in the container repeat, repeated as currentWorkflow:
UNIQUE_BY_KEY(MAP(data.AllFeatures, {value: item.fields.Workflow, value2: item.fields.FeatureLookup}), "value")

This in the List Item 2 repeat, repeated as currentFeature:
MAP(repeated.currentWorkflow.value2, { value: item })

And then the respective binding property for each repeat in the Title 1 and List Item 2 Content and Label.

But the preview looks like this instead of having multiple corresponding Features under each Workflow.

App ID is 120704 if you want to have a look. Thanks!

I checked the source data with debugger, and it looks like the formulas are working correctly – each FeatureLookup just has a single item in the array.

That was it! Thank you. I was thinking about the structure incorrectly. Makes total sense now.