Pulling Data From SQL Into Forms

Fill a Select list with values from a SQL Server table. This example lists vendor names.

Step 1: Prepare SQL Server

  1. In SQL Server Management Studio, open the server's Properties → Security and select SQL Server and Windows Authentication mode.

  2. Under Security → Logins, create a SQL login for GlobalForms, for example svc_globalforms.

  3. In the login's User Mapping, give it access to the database you'll query, with the db_datareader role for read-only lookups.

  4. 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:

JSON
{
  "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

https://forms.example.com/vendorNames

Data Path

rows

Value Property

VendorName, the column whose value is saved

Item Template

<span>{{ item.VendorName }}</span>, which controls what users see

Save the component and test the form.