Unable to access the input field data (and insert into database)

  • Goal: Inserting data from a text input field into the retool database.

  • Steps: I already tried to adjust the query, it's stuck because it says the text input field is scoped within the database page and the query is scoped to the app.

  • Details: May be a simple problem but ChatGPT couldn't help... :slight_smile:

  • Screenshots:
    Screenshot 2024-10-06 160938

2 Likes

Hi @luke3, Welcome to the Retool Community,

Are you building the app in the multi-page app?

1 Like

Depending on where you need to use the data and where the requests come from, you need to set their scope.

If you query is in the app scope, you probably have a page called app and a page called database?

Could you share a screenshot of your page overview and component overview?

You could put the query from app to database. Or you can put it in global. If you reference an input field in a query resource, they have to be in the same scope.

Hey @luke3! Welcome to the community. :wave:

I'll echo those that responded before me and say that it sounds like you're running into scoping issues due to this being a multipage app. The rule is that code defined in a local scope has access to anything defined in the global scope, but not the opposite.

In your case, this query is globally scoped and thus unable to access information that is more narrowly scoped to a particular page. One solution is to move the query into the same page scope. If that's not an option because you need to it to be defined globally, then my recommendation is to create a global variable that you can set from within the page, thus exposing whatever information that is necessary.

I hope that makes sense! Let me know if you have any follow-up questions.

1 Like