Q: Pass data schema from Data.variable to App.variable

Hi,
I’m connecting my app to backend and want to set App.variables from Data.variables.

Do I need to create App.variables schema by hand and then in Data.variables logic prepare to Get Record Collection > Set App Variable > Assign Value again by hand?

Or there is an option to automatically pass whole Data.variables schema together with data?

When I try to use “any value” in App.variable and then try to pass Data.variables it won’t work.

If you want to use the app variable with the schema, you have to create it by hand currently (this is something we are looking to somehow improve in the future). However I often just use the app variable “schemaless”, so set it as an list of objects or an object and remove the id property. When the app variable is schemaless, you have to set it via formula for it to work. The formula editor will complain about incompatible schemas, but it’s only a warning and you can ignore it, because it works. And from the schemaless app variable, you can still use all the fields like in the data variable, but Composer won’t know about them, so you will have to use formulas and just write them up. I mostly use app variables only to then set data variables again, so the logic that I do is the following:

On global canvas, fetch data from endpoint with Get Record Collection and set it to schemaless app variable > On a page, fetch data from app variable and set it to the data variable on the page (removing all other fetch logic for the data variable)

3 Likes

Hi, sorry to revive an old thread, but I am trying to follow your idea to assign my REST API data variables to app variables, then reassign them to data variables on individual pages, as needed. My setup is…

In global canvas: App launch > Get record collection (list of objects with many properties [collection]) > 20 second Delay loop > Set app variable (Set schemaless to data.listOfObjects via formula). Schemaless is app variable, list of objects type, with no properties (id has been deleted). On my page where I want to show repeated list of data: Page mounted > Set data variable (dataClient, client-side storage type) from record collection “schemaless”. On repeated list item: Primary label: data.dataClient.PropertyName, repeat with data.dataClient (both via formula).

Doing the above does not show my list, I only see an empty page. I know I must be missing something obvious with syntax or whatnot. Please help?

EDIT: I should note, if I use the app variable “schemaless” to generate my list, it works fine. The part I’m having trouble with is setting the data variable from the app variable.

EDIT 2: Never mind…I figured out the syntax problem!

1 Like