Help me with this query with a reference to variables

  • Goal: Populate a table using a query from a Supabase database. I'm trying to return data based on a variable currentYear.

  • Steps: When the user clicks on 2012 in the navigation bar, I've got it setup to define the currentYear variable as 2012. But the query returns the error in the screenshot.

  • Details: If I modify the query and have it be '2012' instead of '{{ currentYear }}', the query returns the correct data. There's an error somehow with how the variable is being defined/passed/etc.

  • Screenshots:

Apologies for the odd title of this thread. Typo.

Hello @watsonbriant and welcome to the forums!

A couple of things that stand out to me right away:

  1. the currentYear variable you are using should be referenced with {{currentYear.value}} which should at least supply the data properly, however...
  2. ...it appears that your value is being set AFTER the trigger for the query that uses it. You have a list of events being triggered on a single click but it may be a better idea to chain the events using the Success/Failure handlers on each query. You can also trigger queries using the Run Script event on the current click handler and set your variable or pass relevant component/app data using the additionalScope option .
1 Like


Updated the click event handlers to just run a script (both visible in the screenshot. You can also see how the table isn't populating in the corner. Any ideas?

Do you need the single quotes around your {{currentYear.value}} statement? It should be providing that formatting for you as part of the prepared statement

On this script:
Screenshot 2024-09-27 at 2.19.08 PM

Add await before line 2:
await currentYear.setValue('2012')

setValue is an async function that most likely has not completed by the time showstable is triggered. Which is causing the query to run with the previous value.