Get record from app variable

Hi Appgyver,

I store my backend online database in an app variable when my app opens on the global canvas, this is to avoid the app loading the entire database on every page in the app.

I have an item list page showing data from the app variable but I can send the id to the next page so it knows what item was picked. It works fine with “get record” from the database backend when using the data variable but I can’t get it to work when trying to fetch the data / get a single record from the app variable.

Any suggestions?

Thanks Dan

Hi Dan! If you have a page that takes the ID of a record as a parameter, you can get an individual record from your list type app variable with the formula FIND_BY_KEY(appVars.records, "id", params.id)

Hi @Mari,

I have tried your suggestion and I do get a picture and text on the next page but it does not reflect the option you have chosen in the list item, it just gives me the same picture and text no matter what you pick.

Not sure if I am not sending the correct id or if it’s me not writing the formula correctly.

Hi Dan, if you are repeating the items on your list page, you should pass current.id as the parameter to the page that opens.

Hi @Mari,

Thank you so much for trying to help, I have done that but all I get in the validation is “object is not assignable to text / number type”.

Not sure what I am doing wrong since it was working when I was using a data variable as the source. :worried:

In which field do you get that error?

In formula and I am not getting a result any more.
This is my formula, the List Item page is sending current._id

FIND_BY_KEY(appVars.BrowseposterX, “Product_Name”, appVars.BrowseposterX[0]._id)

Hi, it’s likely because you are not taking the id from the parameter that you passed, but always from BrowseposterX[0]. So change that to params.id or whatever your page parameter is called :slight_smile:

For example if I had a fruit listing and a fruit detail page that takes the name of the fruit as its parameter, this is how I would access the name of the chosen fruit:

image

Thank you Mari, I think I am very close but just not quite there. I am not getting an error anymore :slightly_smiling_face: but still not getting any result coming up.

I have added the ._id to the end as I didn’t have that before. The page parameter is just called id and is set to accept all values.

Hi, maybe it’s that you should select by the _id field, not Product_Name if that’s what you’re passing?

Thank you Mari,

Yep that was it, now both a single picture and text are tracking through just fine. :grinning:

The only thing I struggle with now is I have a row of pictures repeated with
MAP, this is the formula I used to have:
MAP(data.BrowseposterX1.Scroll_Pictures,{id:item})

and the source:

https://BP.restdb.io/media/” + current.id

Not sure how change this so it reference with app variable instead.

Hmm, if you are repeating with appVars.BrowseposterX, “https://BP.restdb.io/media/” + current._id should work

Thanks Mari for all you help. Much appreciated. :+1:

1 Like