Skip to main content

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

TypeWhen to use
ValuesShort, stable list typed in manually — covered in Input Components
Raw JSONHardcoded list you want to define as JSON, not type option by option
CustomDynamic options built from JavaScript — can react to other field values
URLLive data from a URL endpoint — use this for MasterData and external APIs
ResourceNot 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.

  1. Select a Select component → Data tab
  2. Set Data Source Type to Raw JSON
  3. 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.

  1. Select a Select component → Data tab
  2. Set Data Source Type to Custom
  3. Enter JavaScript in the Custom Values box — assign an array of {label, value} objects to values
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:

VariableWhat it meansWhere you'll use it
data.fieldKeyThe stored value of another field on the formCustom Select, conditions, calculations
valuesThe options array for a Custom SelectCustom Values on Select
valueThe value being assigned to the current componentCalculated Value, Calculation tab
show / resultA true/false result for condition logicAdvanced conditions, Calculation tab
input / validThe current field input and validation resultCustom Validation
row.fieldKeyA field value in the same Datagrid rowDatagrid calculations
form / instanceAdvanced access to the form or component contextRare 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.

  1. Select a Select component → Data tab
  2. Set Data Source Type to URL
  3. Enter the endpoint URL in Data Source URL
  4. Set Value Property to value
  5. 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:

URLWhat it returns
/masterdata/osprov%20usersAll OSPROV users — label: name, value: name
/masterdata/useremailsAll 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.

caution

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.

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.

note

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

ProblemLikely cause
Raw JSON dropdown shows nothingJSON is invalid — check for a missing ] or a missing comma between objects. Validate with a JSON linter.
Raw JSON shows wrong values in submissionEach object needs a value key, not just label. With a simple string array, label and value are the same.
Custom dropdown shows nothingCheck you are assigning to values (plural). Also check the array uses {label, value} objects.
Custom dropdown not reacting to another fieldSet Refresh Options On in the Data tab to the field key it depends on.
URL dropdown shows nothingCheck 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 serverSearch Query Name is not set to search.
Link icon does not appear in submissionThe stored value is not numeric — the link only works when the value is a submission ID.