Get Select Options

Extract and display all available options from Single Select or Multiple Select fields in various formats

This script allows you to extract and display all available options from Single Select or Multiple Select fields in your NocoDB database. You can choose to output the options in a simple list, a table format, or as a comma-separated string, making it easy to reference or export the data.

const config = input.config({
  title: 'Get Single or Multiple Select Options',
  description: 'This script outputs all options for a single or multiple select field.',
  items: [
    input.config.table('sourceTable', {
      label: 'Table with the single or multiple select field'
    }),
    input.config.field('selectField', {
      label: 'Single or Multiple Select Field',
      parentTable: 'sourceTable'
    }),
    input.config.select('outputFormat', {
      label: 'Output Format',
      description: 'Choose how you want each option to be displayed.',
      options: [
        { label: 'List', value: 'list' },
        { label: 'Table', value: 'table' },
        { label: 'Comma Separated', value: 'commaSeparated' }
      ]
    })
  ]
});

// Extract configuration values
const table = config.sourceTable;
const field = config.selectField as Field;
const format = config.outputFormat;


if (![UITypes.SingleSelect, UITypes.MultiSelect].includes(field.type)) {
    throw new Error("Please select a Select Field")
}

// Get all available choices from the select field
const choices = field.options.choices;

// Output the choices based on the selected format
switch (format) {
  case 'list':
    choices.forEach(choice => {
      output.markdown(choice.title);
    });
    break;

  case 'table':
    const tableData = choices.map(choice => ({
      'Option Name': choice.title
    }));
    output.table(tableData);
    break;

  case 'commaSeparated':
    const optionNames = choices.map(choice => choice.title);
    const commaSeparatedList = optionNames.join(', ');
    output.markdown(commaSeparatedList);
    break;
}

Use Cases

  • Documentation: Create lists of all available options for field references
  • Data Analysis: Export option lists for external analysis or reporting
  • Field Auditing: Review all configured options in selection fields
  • Integration Setup: Get option lists for API integrations or data mapping
  • User Training: Generate option references for user guides and training materials

Output Formats

The script offers three different output formats to suit your needs:

1. List Format

Option 1
Option 2
Option 3

2. Table Format

| Option |
|--------|
| Option 1 |
| Option 2 |
| Option 3 |

3. Comma-Separated Format

Option 1, Option 2, Option 3

How it Works

  1. Select Field: Choose a Single Select or Multiple Select field
  2. Choose Format: Pick your preferred output format (List, Table, or Comma-separated)
  3. Generate Output: The script displays all available options in the selected format
  4. Copy/Export: Use the formatted output for your intended purpose

Requirements

  • A Single Select or Multiple Select field with configured options
  • The field must have at least one available option defined

Supported Field Types

  • Single Select: Fields where users can choose one option from a predefined list
  • Multiple Select: Fields where users can choose multiple options from a predefined list

Example Scenarios

Single Select Field: "Status"

Available Options: Active, Inactive, Pending, Archived

List Output:

Active
Inactive
Pending
Archived

Table Output:

| Status |
|--------|
| Active |
| Inactive |
| Pending |
| Archived |

Comma-Separated Output:

Active, Inactive, Pending, Archived

Benefits

  • Quick Reference: Instantly see all available options for any selection field
  • Multiple Formats: Choose the output format that best fits your needs
  • Documentation Ready: Generate properly formatted lists for documentation
  • Integration Friendly: Export options in formats suitable for external tools
  • No Manual Copying: Avoid manually transcribing long option lists