What kind of voodoo does it take to be able to use data retreived as object oin a page variable list of objects so it can be repeated?

DATA

PAGE VARIABLE

image

Why will it not allow me to set the data variable as value of the page variable???

You have completely different properties…

In the DATA (5 properties):

  • musicId [text]
  • public [text]
    -title [text]
  • uid [text]
    -url [webURL]

In the page variable you have (4 properties) *This is already enough to fail

  • musicId [text]
  • public [text]
  • title [text]
  • url [any URL]

Another thing: the page variable URL type property is not the same type as tha data “web URL” type of property.

So what you could do is to use a formula like this in the set page variable flow: *of course please change the “data” to your data variable. This will only work if the data is a list of objects and still will throw a warning because of the url type mismatch, but at least it will save.

MAP(data, {musicId: item.musicId, public: item.public, title: item.title, url: item.url}
2 Likes

I had changed the data types and added the missing property. When I made it again to make the screenshot I messed it up. But I cannot get the data as a list of objects. I can only get the data from firebase realtime database as a single object.

The simple mentioning of “realtime” db makes so much difference… Realtime DB returns an object, right?

So you indeed cannot simply map through it as you would need a list for that. But what you could do is to MAP through the KEYS of the response from the Realitme DB. Now taking a more detailed view at your data structure it seems to me that each key in the response is in fact a data record id, and you store the details of that inside the properties of that. So that means that your realtime DB returns an object which has an ever-growing list of properties, which are the ids. So that is not an object from your point of view, but is a list of objects. Still, the response is an object as the realtime DB stores data in an object, that is how it works. So for this what you will need to do is to make use of the KEYS() formula. Okay, let’s get to it:

MAP(KEYS(data.response), {
music_id: LOOKUP(data.response, item).music_id, 
public: LOOKUP(data.response, item).public, 
title: LOOKUP(data.response, item).title, 
url: LOOKUP(data.response, item).url
})

This formula should finally get you your values. Now what the hell is going on there?
First we get all the property names of the data.response with the KEYS() formula, this will become a list of texts, which we use in our MAP() formula as input. Since the MAP() formula refers to the current item of the list of texts as item we use that to find the specific value in the data.response object with the LOOKUP() formula. And that still will only take use to the value that you have in the data.response so we still need to assign the correct properties in the page variable, that is why I used the {} object transform formula. If you have the exact same schema in the page variable as in the data.response.yourgeneratedid then the formula would simply be:

MAP(KEYS(data.response), LOOKUP(data.response, item))

Final thought. If you still only need a few properties only from the data.response you can play around with formula like this, or you can take it even further with some careful consideration:

MAP(KEYS(data.response), PICK_KEYS(LOOKUP(data.response, item), ["music_id", "public", "title", "url"])

But what is most important to understand that the REALTIME DB returns an object, not a list!

Thanks. I will try this. I really wish they would write some docs on their formulas.

none of this is working

I really appreciate your help, as I have been unable to get answers on this for quite some time.

I am still getting this error and have tried changing the url types.

This is just a warning, can you validate that the formulas didn’t get the result in the app? Did you check it with Debugger?

In the Debugger, you can also see the schemas of the variables so which can help in figuring out the issue.

This will for sure throw an error as in the data resource you also have the “uid” property which is not present in the page variable schema… There are more properties in the result array of this formula then what the page variable expects. I thought that I mentioned that above in the long response as well as a note…