Get Select Options
This script gets and shows all available options of a Single Select or Multiple Select field in your NocoDB database. You can show the options as a simple list, as a table or as a comma-separated string. You can then use the options as a reference or export them.
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 as field references.
- Data Analysis: Export option lists for external analysis or reports.
- Field Auditing: Review all configured options in select fields.
- Integration Setup: Get option lists for API integrations or data mapping.
- User Training: Create option references for user guides and training materials.
Output Formats
The script has three output formats:
1. List Format
Option 1
Option 2
Option 32. Table Format
| Option |
|--------|
| Option 1 |
| Option 2 |
| Option 3 |3. Comma-Separated Format
Option 1, Option 2, Option 3How it Works
- Select Field: Select a Single Select or Multiple Select field.
- Choose Format: Select an output format (List, Table or Comma-separated).
- Generate Output: The script shows all available options in the selected format.
- Copy/Export: Copy or export the formatted output for your purpose.
Requirements
- A Single Select or Multiple Select field with configured options
- The field must have at least one option
Supported Field Types
- Single Select: Users select one option from a predefined list.
- Multiple Select: Users select one or more options from a predefined list.
Example Scenarios
Single Select Field: "Status"
Available Options: Active, Inactive, Pending, Archived
List Output:
Active
Inactive
Pending
ArchivedTable Output:
| Status |
|--------|
| Active |
| Inactive |
| Pending |
| Archived |Comma-Separated Output:
Active, Inactive, Pending, ArchivedBenefits
- Quick Reference: See all available options of a select field at once.
- Multiple Formats: Select the output format that fits your needs.
- Documentation Ready: Get correctly formatted lists for documentation.
- Integration Friendly: Export options in formats that external tools can use.
- No Manual Copying: You do not have to copy long option lists by hand.
Last updated on
Latest product updates?See Changelog