Category: How do I do X?


This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Is it possible to pass a variable to a DataSource query when binding data to a widget?


I am a newbie with Appsmith and I want to know if it's possible to pass a query a variable to modify the data coming back from the query to the widget. My use case is that I have a query that returns a list of items, which belong to categories, and I want to pass a parameter to the query in order to use it in a WHERE statement to filter the results. However, when I try to do this with the run method, I get an error saying that I cannot execute framework actions in a sync field. Can someone help me with this issue?


The user is attempting to pass a parameter to a query in Appsmith when binding data to a widget. They want to modify the data coming back from the query based on a user's selection. After attempting to use {{{catValue: 1})}} and encountering an error, they seek a solution.

Amelia suggests that the reason this does not work is because the user is running an async method in a sync field. To fix this, they recommend creating a JS function inside a JS Object that runs on page load and runs the query with the desired parameter from there.

The user expresses gratitude and plans to try this solution.