Datasets

Datasets provide lookup data from the KASKO Data Service. They enable autocomplete inputs, field mapping, and dynamic data integration.

How Datasets Work

  1. A field is configured with the in_dataset:DATASET_ID validation rule

  2. The user selects/enters a value using a dataset component

  3. The selected item's ID (prefixed with dai_) is stored in the field

  4. The framework fetches the full dataset item

  5. The dataset item is exposed under the dataset namespace

Dataset Item Structure

When a dataset item is loaded, it looks like this:

{
  id: string;           // Dataset item ID (e.g., "dai_abc123...")
  dataset_id: string;   // Dataset ID (e.g., "dat_xyz789...")
  [key: string]: any;   // Arbitrary data fields from the dataset
}

Dataset Components

form-data-input

Typeahead/autocomplete input:

Config
Description

field_name

Field that stores the dataset item ID

data_field_name

Dataset field used for search/display

field_map

Maps form fields to dataset fields (auto-fill on selection)

filter_by

Filter dataset results by criteria

sort

Sort results: "asc" or "desc"

wait_ms

Debounce time in milliseconds

min_length

Minimum characters before search triggers

clear_fields_on_change

Fields to clear when selection changes

form-data-lookup

Dropdown lookup:

dataset-map

Invisible mapper that fills additional fields when a dataset item loads:

Validation

Fields using datasets must include the in_dataset rule:

  • First argument is the dataset ID (starts with dat_)

  • Backend validates the value exists in the dataset

  • Frontend ignores validation for in_dataset, but dataset lookup still requires it

Accessing Datasets in JsonLogic

Dataset items are available under the dataset namespace:

Access fields:

Accessing Datasets in Content

Use dataset tokens in translations:

Repeaters

Datasets work with repeater fields:

Each repeater item has its own dataset entry:

  • dataset.data.agents.0.location

  • dataset.data.agents.1.location

Filtering Results

Basic filters:

Advanced filters:

Automatic Cleanup

When a dataset field is cleared or changed:

  • The old dataset item is removed from state

  • Prevents stale data from accumulating

Tips

  • Use field_map or dataset-map to auto-fill related fields

  • Keep field_name aligned with the form field path (e.g., data.company)

  • Use clear_fields_on_change to reset dependent fields when selection changes

Last updated