Custom Field: Structured Data (Json) Type

  • You must be an Administrator to add custom fields.

  • Custom Fields are Registry wide.

The Aristotle Metadata Registry allows site administrators to add their own custom fields to metadata items. Currently, the custom fields support data types such as integers, text, rich text, date, and choice.

To enhance customisation, we're introducing a new 'Structured Data (Json)' custom field type. This feature enables clients to create their own custom fields using JSON Schema, which will describe what values are allowed for the custom field’s value and provide information for generating user interfaces for display and editing.

This help page exclusively covers the 'Structured Data (JSON)' custom field type. For more information on custom fields, please visit this link.

With this update, you can now add multiple custom fields at once using the 'Structured Data (JSON)' type. Administrators can define these fields by adding JSON code in the JSON Schema, as shown in this reference link: https://json-schema.org/.

You can configure the editor layout by writing JSON forms code, accessible through 'Open Item Editor' and the 'Slots' tab. Reference this link for guidance: https://jsonforms.io/.

Additionally, you can define the View layout using JSON or Jinja, determining how it appears on the item page.

Let's look at an example to gain a better understanding of how the 'Structured Data (JSON)' type works:

  1. I have the 'Employee Information Dataset' below and would like to add details of Aristotle Metadata employees, including their names, positions, and contact emails. I can say that I kind of want to add a reference data for this dataset.

  1. The easiest way to do this is to add a custom field named 'Employee Details.' To do so, go to 'Administrator Tools', then click on 'Manage Custom Fields'.

  1. I will add the custom field for 'All'. Alternatively, you can choose to add it for the 'Data Set' only.

  1. Click on 'Add Custom Field for All Models.' Name it 'Employee Details,' select the Type as 'Structured Data (JSON),' and assign a system name of your choice.

  1. Scroll down and select the visibility as 'Public' and State as 'Active & Visible'. Copy and paste the below codes:

Json Schema -

{
  "type": "array",
  "items": {
    "type": "object",
    "required": [
      "name",
      "position",
      "contactEmail"
    ],
    "properties": {
      "name": {
        "type": "string"
      },
      "position": {
        "type": "string"
      },
      "contactEmail": {
        "type": "string",
        "format": "email"
      }
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Editor Layout -

{
  "type": "Control",
  "label": "People",
  "scope": "#/properties",
  "options": {
    "detail": {
      "type": "HorizontalLayout",
      "elements": [
        {
          "type": "Control",
          "scope": "#/properties/name"
        },
        {
          "type": "Control",
          "scope": "#/properties/position"
        },
        {
          "type": "Control",
          "scope": "#/properties/contactEmail"
        }
      ]
    }
  }
}

View Layout -

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Position</th>
      <th>Contact Email</th>
    </tr>
  </thead>
  <tbody>
    {% for employee in value %}
      <tr>
        <td>{{ employee['name'] }}</td>
        <td>{{ employee['position'] }}</td>
        <td>{{ employee['contactEmail'] }}</td>
      </tr>
    {% endfor %}
  </tbody>
</table>
  1. Click on 'Submit Edits'.

  2. Navigate to any metadata item; in this case, I'm returning to my 'Employee Information Dataset.' Click on 'Actions,' then select 'Open Item Editor.' Proceed to the 'Slots' tab, where you'll find 'Employee Details.' You can add as many employee details as you need and then click 'Save Changes'.

  1. This is how it appears on the item page after saving.

  1. Similarly, you can add as many custom fields as you'd like by including JSON codes for each.

Last updated