Data Sources (beta)

Data sources functionality is in beta testing and may be subject to change.

The data source is an attribute of a list field. It allows using collection field values as list field options.

Example

We have a collection of player names called "Team" and want to use names from this collection as available values for a list field named "Captain". Here is how "Team" and "Captain" fields may be specified in project settings JSON.

{
  "sections": [
    {
      "name": "Data Sources",
      "properties": [
        {
          "label": "Team",
          "key": "team",
          "field": "base_collection"
        }
      ]
    },
    {
      "name": "Fields",
      "properties": [
        {
          "label": "Captain" 
          "key": "captain",
          "field": "player_name_selector"
        }
      ]
    }
  ]
}

Here are field definitions from fields JSON.

[
  {
    "key": "text",
    "type": "freetext",
    "localisable": false
  },
  {
    "key": "base_collection",
    "type": "collection",
    "fieldset": [
      {
        "key":"name",
        "field": "text",
        "label": "Name"
      }
    ]
  },
  {
    "key": "player_name_selector",
    "type": "list",
    "data": [],
    "source": {
      "field": "$$PROJECT_FIELDS.team",
      "value_key": "name"
    }
  }
]

The source object in player_name_selector specifies to use "Team" collection as a data source. $$PROJECT_FIELDS.team from source.field is an absolute path to the "Team" collection.

Attribute source.value_key specifies that the field name in the "Team" collection is used to build values for the list.

Restrictions

  • Only fields of type list from Experience Setup can have a data source.

  • If the field definition has a source attribute then the data attribute must have an empty array as a value - "data": [].

  • Only non-localisable fields of type freetext, datetime and colour can be used as a source of values (source.value_key).

  • Only collections from Experience Setup can be used as a data source.