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.

How do I populate a select widget with the values from Table B in SQL which, when the form is updated, writes the value into Table A?


I am creating a form in a modal to update user details. One of the input fields is related to another table and needs to be populated by a select widget that fetches values from that table. I want the widget to display the existing value from the related table when the form is opened and write the selected value back into the original table when the form is updated. Can anyone help me achieve this in Appsmith?


The solution involves creating a Select widget in a modal form in Appsmith that fetches all the values from the table "Contracts" (including "ContractID" and "Contract_Name") and uses a query to populate the options displayed to the user. To ensure the Select widget writes back the value selected by the user into the related column "Type_ContractID" in the "Users" table, a binding is created between the Select widget's value property and the column "Type_ContractID" in the "Users" table.

To display the existing value of "Type_ContractID" in the Select widget when the form is opened, a query is created that fetches the related value "Contract_Name" from the "Contracts" table based on the value of "Type_ContractID" in the "Users" table. This query is then used to set the initial value of the Select widget.

Conditional population of the options displayed in the Select widget can also be achieved using the Appsmith's functionality.