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
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.
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?
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.
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.
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.
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
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:
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:
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:
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:
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:
(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”
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.
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.