I need to load data in the background instead of in real time on every page load. The REST API is slow to deliver data, but I need to access all the data it is retrieving to make the app. This API does not have an option to load portions, it is all or nothing. I need to repeat with the datavar to create a list of status items.
I thought the global canvas would be that, but it seems to execute on any click.
Is global canvas execution active on every click?
Do I have to create a page that loads 1st time into the app and then pass control on to pages in the navigation list ? that first time page would have a utility-delay to reload data from a REST API.
Basically, I need variables that I can access at anytime that contain data that is loaded every two minutes in the background. I expect these must be appvars and datavars.
I followed examples in tutourials and forum of how to create a data resource, go to a page, create a data variable as instructed, bind with an item list and preview the page.
Latter I tried to make an appvar flag that when set true wait 5 min. All that did was force the screen blank and wait 5 minutes before update.
Objective:
Load data from API the first time you go to the pagre or app.
(from your note use even App Launched in Global Canvas)
Don’t create a datavar ?? Instead make a timing loop here on global canvas and populate an appvar.
Use appvar on anypage and it WILL NOT be reinitialized each time that page is opened???
I think I have tried someting like but did not use the App Launched event and I always was barred from using “Repeat with” unles I used the datavar.
Can you sumarize or send link describing page/app/data var types and example use? Confusing when to use simple text vs complex object, any value and list?
As seems anytime I created a datavar object from a data resource then set an appvar object type I don’t seem to be able to use the appvar object in the same way the datavar object can be used.
Is it a GetCollection REST API? If yes how much time your Data Source takes to retrieve the full payload (which would be a json array of records); I am asking because in one of my app I am doing sth similar to what @Mevi has advised above. I call GetCollection and load the entire payload to a global app variable. Then I use a java script function flow and a timer to loop through the array of records. The GetCollection call retrieves a couple of hundreds of data records; Each data record is a quite big json structure with pointers to other assets like images an others that will need to be fetched asynchronously. On a side note, the global app variable should be of any value type which translates into raw json but can be mapped into your record structure. I hope that helps. Piotr
I now have a Global Canvas flow that loops getting datavar and then assigning it to an appvar.
Two issues I have found are:
the data schema does not follow from datavar to appvar assignment. So I have to use 100% formulas to access data and hope to remember the schema each time.
Not related to 1 above, I am trying to use a formula to assign a query param and it does not work. Not sure how to see the data collection query for trouble shooting.
This works
The schema of the data variable and app variable has to match exactly to work, and the tiniest difference will make it not work (requiring you to use formulas). I recommend taking a screenshot from the data tab of the schema that the data resource has and comparing it to the app variable schema
Have you checked elsewhere that the NOW() formula works like you would expect it to, so that it comes out in the correct format? If it doesn’t, use FORMAT_DATETIME_LOCAL(NOW(), “PUT_YOUR_DATETIME_FORMAT_HERE”)) instead.
yes now() works in alert shows what i want. does not send the same thing in query. query gets no data but not sure how to see the query url.
i think something is missing here. i should not have to type in the schema of a 100 properties and nested arrays etc. i should be able to set appvar identically to the datavar complete with schema.
i have 12 or more and manually keeping them in sync is really a goofy idea.
how can i set datavar schema to another xxxvar type schema in automation???