Using string-list and enum-list Field Types for Multi-Value Fields

Last updated: May 16, 2025

When working with fields that need to accept multiple values (like multiple email addresses or multiple category tags), Flatfile provides two specialized field types:

Field Types for Multiple Values

  • string-list: For fields that accept multiple text values (e.g., multiple email addresses)

  • enum-list: For fields that accept multiple values from a predefined list of options

Handling Comma-Separated Values

When importing data where multiple values are separated by commas in a single column, you'll need to add a record hook to split the values properly. Here's how to implement it:


listener.use(
  recordHook("staging", (record: FlatfileRecord) => {
    const value = record.get("fieldName");
    if (Array.isArray(value)) {
      for (const item of value) { 
        if (typeof item === "string") {
          const trimmedValue = item.trim();
          if (trimmedValue.includes(',')) {
            const items = trimmedValue.split(',')
              .map(e => e.trim())
              .filter(e => e !== "");
            if (items.length > 0) {
              record.set("fieldName", items);
            }
          } 
        } 
      } 
    } 
    return record;
  })

Blueprint Configuration Example

Here's how to configure these field types in your blueprint:


{
  "fields": [
    {
      "key": "email_addresses",
      "label": "Email addresses",
      "type": "string-list",
      "constraints": [
        {
          "type": "unique"
        }
      ]
    },
    {
      "key": "categories",
      "label": "Categories",
      "type": "enum-list",
      "config": {
        "options": [
          {
            "value": "option1",
            "label": "Option 1"
          },
          {
            "value": "option2",
            "label": "Option 2"
          }
        ]
      }
    }
  ]
}

The enum-list type requires you to define all possible options in the blueprint configuration. Users will be able to select multiple values from this predefined list.