I’m using the Metropolitan Museum of Arts REST API. I can set this up quite easily in the Data Confirguator and create variables to hold the data. The problem comes when trying to create a list/gallery/etc using that data. The MET API (ASFAIK) can only generate a list of of id’s that match a search criteria, or a length record of one id. It cannot return anything that is a list of multiple parameters of multiple object id’s.
For example: The collection request returns just a list of id’s:
Each of those has to be queried individually to get the full list of parameters I’m interested in:
So I can create a list item or card with parameters from one id, but I am stumped at how to iterate though the list of id’s to show them all in a gallery or list.
Hi, you can do this by looping flow functions on the Logic Canvas.
I made this pseudo flow where there are 2 page variables
itemList. In the beginning you would populate
idList with all the id’s you want to retrieve information for, and
itemList is an empty list with a schema that matches the objects you want to retrieve.
The flow starts by checking if there are any id’s left to retrieve. If yes, get a record with the first id in the list. Then save that output to
itemList. Then remove the used id from
idList and check again.
Once all id’s have been used and removed,
itemList should have all the desired items and execution of the loop stops when the IF condition node returns “true” because
idList is empty.
Thanks Mari, that worked great it took me a while. When I went looking for the APPEND and REMOVE functions I couldn’t find them. What I ended up with is
. It took some trial and error. Why couldn’t I find the same functions as you suggested. Is your composer a different version?
Also it seems like the options for the first element in a repeating component only shows suitable options when the “Repeat With” option is set. Since that is underneath the first element options it’s not at all obvious that that has to be set first. Maybe the “Repeat With” option should be moved to the top and then what follows will be in context.
REMOVE are just aliases for
WITHOUT_ITEM, sorry for forgetting to mention that.
Thanks for the feedback on the ordering of properties. I think the “Repeat With” option is placed at the bottom since every component can be used either by itself or as a repeated component, so the line between what is a “repeated component” and what is not is a little blurry. It could be a good feature if components that will likely be repeated, such as list items, would have the “Repeat With” option at the top.
Maybe instead of moving the “Repeat With” option to the top, put a checkbox of switch at the top that says something like “Use a Repeated Component”? That then sets the context for the all the rest of the options.