Data Sources and Dynamic Options
A Select component in OSPROV does not have to hold a static list of options. You can load options from JSON, JavaScript, or a live data endpoint. This page covers all five data source types and when to use each.
Data Source Types
| Type | When to use |
|---|---|
| Values | Short, stable list typed in manually — covered in Input Components |
| Raw JSON | Hardcoded list you want to define as JSON, not type option by option |
| Custom | Dynamic options built from JavaScript — can react to other field values |
| URL | Live data from a URL endpoint — use this for MasterData and external APIs |
| Resource | Not applicable in OSPROV — ignore this option |
Raw JSON
Use Raw JSON when the list is too long to type option by option but does not change over time.
- Select a Select component → Data tab
- Set Data Source Type to Raw JSON
- Paste a JSON array into the Data Source Raw JSON field
[
{"label": "IT", "value": "it"},
{"label": "Finance", "value": "finance"},
{"label": "Human Resources", "value": "hr"},
{"label": "Operations", "value": "ops"}
]
Each object needs a label (what the submitter sees) and a value (what gets stored). If the label and stored value are the same, you can use a simple string array:
["IT", "Finance", "HR", "Operations"]
The JSON lives inside the form schema. If the list changes, you edit the form and republish. Use URL/MasterData instead if the list needs to stay up to date without touching the form.
Custom (JavaScript)
Use Custom when the options need to be built dynamically — for example, when they depend on what the user has selected in another field.
- Select a Select component → Data tab
- Set Data Source Type to Custom
- Enter JavaScript in the Custom Values box — assign an array of
{label, value}objects tovalues
values = [
{ label: 'Laptop', value: 'laptop' },
{ label: 'Monitor', value: 'monitor' },
{ label: 'Keyboard', value: 'keyboard' }
];
Reacting to another field
Read another field's current value using data.fieldKey:
values = data.department === 'it'
? [{ label: 'Laptop', value: 'laptop' }, { label: 'Server', value: 'server' }]
: [{ label: 'Desk', value: 'desk' }, { label: 'Chair', value: 'chair' }];
For the options to update when the other field changes, set Refresh Options On in the Data tab to the field key it depends on. Without this, options are only computed once when the form loads.
JavaScript variable reference
These are the variable names available in OSPROV's code boxes:
| Variable | What it means | Where you'll use it |
|---|---|---|
data.fieldKey | The stored value of another field on the form | Custom Select, conditions, calculations |
values | The options array for a Custom Select | Custom Values on Select |
value | The value being assigned to the current component | Calculated Value, Calculation tab |
show / result | A true/false result for condition logic | Advanced conditions, Calculation tab |
input / valid | The current field input and validation result | Custom Validation |
row.fieldKey | A field value in the same Datagrid row | Datagrid calculations |
form / instance | Advanced access to the form or component context | Rare advanced cases |
Variables are case-sensitive. data.department and data.Department are different. Use lowercase field keys to avoid confusion.
URL / MasterData
A Select field can load its options from any URL that returns a JSON array. OSPROV's built-in MasterData system is the most common use of this.
- Select a Select component → Data tab
- Set Data Source Type to URL
- Enter the endpoint URL in Data Source URL
- Set Value Property to
value - Leave Item Template as the default unless you need custom display formatting
Built-in MasterData endpoints
OSPROV ships with two ready-to-use data sources:
| URL | What it returns |
|---|---|
/masterdata/osprov%20users | All OSPROV users — label: name, value: name |
/masterdata/useremails | All OSPROV users — label: name, value: email address |
Use osprov%20users when you want to capture a person's name. Use useremails when you need their email address — for example, to send a notification to whoever is selected. Note the %20 in the URL — that is URL-encoding for a space. Copy it exactly.
Custom MasterData tables
Your organisation can add custom MasterData tables. These are populated in two ways:
- Workflow Output task — when a workflow completes, an Output task pushes a value into a MasterData table. Forms can then load that table as a dropdown, ensuring submitters only see current, approved data.
- Manual JSON — an administrator enters a JSON array directly. Useful for static reference data like country lists, cost centres, or product codes.
To use a custom table, the URL is /masterdata/{table name} — where the table name matches exactly what appears in Admin → MasterData, including spaces and casing.
JSON-type MasterData tables may return data in a different shape from workflow-backed tables. Verify the table is returning data correctly with your administrator before using it in a published form.
Server-side search
The Select component shows a search box to submitters by default. To make that search filter the server data as they type (rather than only filtering already-loaded options), set Search Query Name to search in the Data tab. This matters for large tables.
Linked Submission Behaviour
When a Select field stores a numeric value, OSPROV automatically displays a link icon next to that field in the submission view. Reviewers can click the icon to open the related submission directly — no configuration needed.
This happens most often when a MasterData table is populated from workflow submissions, which use the submission ID (a number) as the stored value.
The link icon only appears when the stored value is numeric. JSON-type MasterData tables typically store text values, so the link will not appear for those.
Troubleshooting
| Problem | Likely cause |
|---|---|
| Raw JSON dropdown shows nothing | JSON is invalid — check for a missing ] or a missing comma between objects. Validate with a JSON linter. |
| Raw JSON shows wrong values in submission | Each object needs a value key, not just label. With a simple string array, label and value are the same. |
| Custom dropdown shows nothing | Check you are assigning to values (plural). Also check the array uses {label, value} objects. |
| Custom dropdown not reacting to another field | Set Refresh Options On in the Data tab to the field key it depends on. |
| URL dropdown shows nothing | Check the table name is spelled exactly as it appears in MasterData, including spaces and casing. Verify the table has data. |
| Submitted value is blank (URL) | Value Property is not set to value. Fix in the Data tab. |
| Search filters locally but not on the server | Search Query Name is not set to search. |
| Link icon does not appear in submission | The stored value is not numeric — the link only works when the value is a submission ID. |