I'm having trouble understanding why a UI component within a multi-page app is considered out of scope for a javascript code query i'm trying to use that references the UI component's scope.
In the screenshots below, you can see that the editor is suggesting that "table2", which is a Page table component, is out of scope. this happens regardless of whether my javascript code query is located in the Global OR Page level. My questions:
Is this a bug or an intended feature?
How would I access the table2 scopes via this code query?
@Isabella_Borkovic i tried that but i'm still getting out of scope issues for page-scoped queries referencing page scoped queries AND page scoped queries referencing page scoped components. Any further comment regarding this one?
If you read my original post, i wrote that this happens regardless of whether my query is page scoped OR global scoped. For ease of re-reading, i've included a screenshot of a page-scoped query showing the warning editor for a page-scoped component:
Ah, sorry for not reading your initial post carefully enough! Does the query run correctly despite the scope errors? Sometimes false scope errors can pop up, but the code itself may still run as expected.
Also, if possible, would you be able to email me a copy of your app JSON at ibork@retool.com?
I've gone ahead and just now sent a copy of my app JSON.
Regarding your question, it seems to run correctly in some cases, but also not in others.
Additionally, with regard to your earlier comment:
Page-scoped components are not accessible from global queries—you would probably want to convert that global query to be page scoped!
Hmm... why wouldn't page-scoped components not be accessible from global queries? Wouldn't the point of global scoped queries be so that they can access all scoped components, global or page-scoped? Otherwise, why would it be called a global scope? Apologies for not quite understanding this....
Actually, neither scenario is entirely correct. Page-scoped plugins can access both page-scoped and globally-scoped plugins, but globally-scoped plugins can only access other globally-scoped plugins. This documentation provides more details, but the main reason for this structure is that multipage apps use deferred evaluation—page plugins are only loaded when you navigate to the corresponding page. As a result, global plugins don’t always have access to data from page plugins and are therefore limited to interacting with other global plugins.
I am building an application for a checklist. I want to choose a row in a table of saved work and then populate the many different pages with data relevant to this first selection. How would I accomplish this?
Like the OP I would have assumed that I could use a globally scoped query from an event from this page. However I cannot even see the relevant table data in the globally scoped query even while I am on the page in question:
ETA: I'm reading more on the global variable setup, which seems like what I am looking for!
It means a few more event handlers, but at least it makes sense this way.
@Isabella_Borkovic I have the scenario exactly as you described -- Retool shows out-of-scope error for a page-scope JS to access a page-scope component, but it runs fine. How to fix this?