Fill a Select list with values from a SQL Server table. This example lists vendor names.
Step 1: Prepare SQL Server
-
In SQL Server Management Studio, open the server's Properties → Security and select SQL Server and Windows Authentication mode.
-
Under Security → Logins, create a SQL login for GlobalForms, for example
svc_globalforms. -
In the login's User Mapping, give it access to the database you'll query, with the db_datareader role for read-only lookups.
-
In SQL Server Configuration Manager, enable TCP/IP for the instance and restart it if you made changes. For a named instance, make sure the SQL Server Browser service is running.
Step 2: Create the route
Add a Resquel route to config\local.json (see Setting Up SQL Lookups (Resquel) for the full connection settings), then restart the GlobalForms service:
{
"method": "get",
"endpoint": "/vendorNames",
"query": "SELECT DISTINCT VendorName FROM Vendors WHERE VendorName IS NOT NULL ORDER BY VendorName;"
}
Open https://forms.example.com/vendorNames in a browser. You should see the vendor names in the response.
Step 3: Connect a Select component
In the form builder, add a Select component and set these on its Data tab:
|
Setting |
Value |
|---|---|
|
Data Source Type |
URL |
|
Data Source URL |
|
|
Data Path |
|
|
Value Property |
|
|
Item Template |
|
Save the component and test the form.