Skip to content

Commit 5d6e1de

Browse files
Merge pull request #86 from nocodb/docs/script-corrections
2 parents 43e4035 + 6617d3c commit 5d6e1de

26 files changed

+113
-71
lines changed

content/scripts/api-reference/base.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ In every script, you have access to a global `base` object that represents the c
1616

1717
## Properties
1818

19-
| Property | Type | Description |
20-
| -------- | ---- | ----------- |
21-
| `id` | `string` | The unique identifier of the base |
22-
| `name` | `string` | The name of the base |
23-
| `tables` | `Table[]` | Array of all tables in the base with their fields and views |
19+
| Property | Type | Description |
20+
|-----------------------|------------------|--------------------------------------------------------------------------------------|
21+
| `id` | `string` | The unique identifier of the base |
22+
| `name` | `string` | The name of the base |
23+
| `tables` | `Table[]` | Array of all tables in the base with their fields and views |
2424
| `activeCollaborators` | `Collaborator[]` | Array of active collaborators having access to this base (with read-only properties) |
2525

2626
## Methods
@@ -47,7 +47,7 @@ Both the table name and table ID are case-sensitive.
4747
const projects = base.getTable('Projects');
4848

4949
// Get a table by ID
50-
const tasks = base.getTable('tbl123456789');
50+
const tasks = base.getTable('m123456789');
5151

5252
// Check if a table exists
5353
const tableName = 'Customers';
@@ -222,7 +222,7 @@ if (teamMember) {
222222
}
223223

224224
// You can also search by ID or name
225-
const memberById = base.getCollaborator('usr_123456');
225+
const memberById = base.getCollaborator('u123456789'); // Replace with actual ID
226226
const memberByName = base.getCollaborator('John Doe');
227227

228228
// getCollaborator returns null if no match is found

content/scripts/api-reference/collaborator.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ This object enables user identification, tracking ownership, assigning responsib
1919

2020
## Properties
2121

22-
| Property | Type | Description |
23-
| -------- | ---- | ----------- |
24-
| `id` | `string` | The unique identifier of the collaborator (read-only) |
25-
| `name` | `string \| null` | The display name of the collaborator (read-only, may be null if not set) |
26-
| `email` | `string` | The email address of the collaborator (read-only) |
22+
| Property | Type | Description |
23+
|----------|------------------|--------------------------------------------------------------------------|
24+
| `id` | `string` | The unique identifier of the collaborator (read-only) |
25+
| `name` | `string \| null` | The display name of the collaborator (read-only, may be null if not set) |
26+
| `email` | `string` | The email address of the collaborator (read-only) |
2727

2828
**Note:** All Collaborator properties are read-only and cannot be modified.
2929

@@ -80,7 +80,7 @@ When a table has a User field type, `getCellValue()` returns a Collaborator obje
8080
```javascript
8181
// Get a record from the Tasks table
8282
const tasksTable = base.getTable('Tasks');
83-
const taskRecord = await tasksTable.selectRecordAsync('rec123456');
83+
const taskRecord = await tasksTable.selectRecordAsync('123');
8484

8585
// Get the assigned user (assuming 'Assigned To' is a User field)
8686
const assignedTo = taskRecord.getCellValue('Assigned To');
@@ -113,7 +113,7 @@ The `CreatedBy` and `LastModifiedBy` field types return Collaborator objects:
113113
```javascript
114114
// Get a record with system user fields
115115
const recordsTable = base.getTable('Documents');
116-
const document = await recordsTable.selectRecordAsync('rec123456');
116+
const document = await recordsTable.selectRecordAsync('123');
117117

118118
// Get the user who created the record
119119
const createdBy = document.getCellValue('Created By');

content/scripts/api-reference/cursor.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ This contextual awareness helps you create scripts that respond intelligently to
1919

2020
## Properties
2121

22-
| Property | Type | Description |
23-
| -------- | ---- | ----------- |
24-
| `activeBaseId` | `string` | The ID of the currently active base |
25-
| `activeTableId` | `string \| null` | The ID of the currently active table, or `null` if no table is active |
26-
| `activeViewId` | `string \| null` | The ID of the currently active view, or `null` if no view is active |
27-
| `row` | `Record < string, unknown > \| null` | The data of the currently selected row, or `null` if no row is selected |
22+
| Property | Type | Description |
23+
|-----------------|--------------------------------------|-------------------------------------------------------------------------|
24+
| `activeBaseId` | `string` | The ID of the currently active base |
25+
| `activeTableId` | `string \| null` | The ID of the currently active table, or `null` if no table is active |
26+
| `activeViewId` | `string \| null` | The ID of the currently active view, or `null` if no view is active |
27+
| `row` | `Record < string, unknown > \| null` | The data of the currently selected row, or `null` if no row is selected |
2828

2929
## Usage Examples
3030

content/scripts/api-reference/field.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ NocoDB supports a wide variety of field types to accommodate different kinds of
1919

2020
All Field objects share these common properties:
2121

22-
| Property | Type | Description |
23-
| -------- | ---- | ----------- |
24-
| `id` | `string` | The unique identifier of the field |
25-
| `name` | `string` | The display name of the field |
26-
| `type` | `UITypes` | The type of the field (e.g., SingleLineText, Number, Date) |
27-
| `description` | `string \| null` | The description of the field (if any) |
28-
| `isComputed` | `boolean` | Whether the field value is computed rather than directly editable |
29-
| `options` | `object \| null` | Type-specific options for the field |
22+
| Property | Type | Description |
23+
|---------------|------------------|-------------------------------------------------------------------|
24+
| `id` | `string` | The unique identifier of the field |
25+
| `name` | `string` | The display name of the field |
26+
| `type` | `UITypes` | The type of the field (e.g., SingleLineText, Number, Date) |
27+
| `description` | `string \| null` | The description of the field (if any) |
28+
| `isComputed` | `boolean` | Whether the field value is computed rather than directly editable |
29+
| `options` | `object \| null` | Type-specific options for the field |
3030

3131
## Common Methods
3232

@@ -633,7 +633,7 @@ const reviewers = record.getCellValue('Reviewers');
633633
const statusField = projectsTable.getField('Status');
634634

635635
// Get a field by ID
636-
const titleField = projectsTable.getField('fld123456');
636+
const titleField = projectsTable.getField('c123456');
637637

638638
// Check field properties
639639
if (statusField) {

content/scripts/api-reference/input.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const subject = await input.textAsync('Enter email subject:');
3939
output.text(`Email subject: ${subject}`);
4040
```
4141

42+
**Output:**
43+
![Text Input Example](/img/v2/scripts/input-text-1.png)
44+
4245
### input.buttonsAsync()
4346

4447
Presents the user with buttons to choose from.
@@ -64,6 +67,9 @@ const status = await input.buttonsAsync(
6467
output.text(`Selected status: ${status}`);
6568
```
6669

70+
**Output:**
71+
![Button Input Example](/img/v2/scripts/input-button-1.png)
72+
6773
**Example with button options:**
6874
```javascript
6975
// Ask for confirmation with styled buttons
@@ -83,6 +89,9 @@ if (confirmation) {
8389
}
8490
```
8591

92+
**Output:**
93+
![Button Input Example](/img/v2/scripts/input-button-2.png)
94+
8695
### input.selectAsync()
8796

8897
Presents a dropdown menu of options for the user to choose from.
@@ -103,6 +112,9 @@ const department = await input.selectAsync(
103112
output.text(`Selected department: ${department}`);
104113
```
105114

115+
**Output:**
116+
![Select Input Example](/img/v2/scripts/input-select-1.png)
117+
106118
**Example with label/value objects:**
107119
```javascript
108120
// Ask user to select a priority level
@@ -117,6 +129,9 @@ const priority = await input.selectAsync(
117129
output.text(`Selected priority level: ${priority}`);
118130
```
119131

132+
**Output:**
133+
![Select Input Example](/img/v2/scripts/input-select-2.png)
134+
120135
### input.fileAsync()
121136

122137
Prompts the user to upload a file.
@@ -150,6 +165,9 @@ if (result && result.parsedContents) {
150165
}
151166
```
152167

168+
**Output:**
169+
![File Input Example](/img/v2/scripts/input-file-1.png)
170+
153171
### input.tableAsync()
154172

155173
Prompts the user to select a table from the base.
@@ -172,6 +190,9 @@ for (const field of table.fields) {
172190
}
173191
```
174192

193+
**Output:**
194+
![Table Input Example](/img/v2/scripts/input-table-1.png)
195+
175196
### input.viewAsync()
176197

177198
Prompts the user to select a view from a specified table.
@@ -196,6 +217,9 @@ const records = await view.selectRecordsAsync();
196217
output.text(`This view contains ${records.records.length} records.`);
197218
```
198219

220+
**Output:**
221+
![View Input Example](/img/v2/scripts/input-view-1.png)
222+
199223
### input.fieldAsync()
200224

201225
Prompts the user to select a field from a specified table.
@@ -231,6 +255,9 @@ for (const record of records.records) {
231255
output.text(`The field "${field.name}" has values in ${nonEmptyCount} out of ${records.records.length} records.`);
232256
```
233257

258+
**Output:**
259+
![Field Input Example](/img/v2/scripts/input-field-1.png)
260+
234261
### input.recordAsync()
235262

236263
Prompts the user to select a record from a table, view, or set of records.
@@ -270,6 +297,9 @@ if (record) {
270297
}
271298
```
272299

300+
**Output:**
301+
![Record Input Example](/img/v2/scripts/input-record-1.png)
302+
273303
## Practical Examples
274304

275305
### Form-Based Data Entry

content/scripts/api-reference/output.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ output.text(`Records processed: ${recordCount}`);
3737
output.text(`Success: ${isSuccess}`);
3838
```
3939

40+
**Output:**
41+
![output.text example](/img/v2/scripts/output-text.png)
42+
4043
### output.markdown()
4144

4245
Renders text with Markdown formatting.
@@ -75,6 +78,9 @@ output.markdown('## Example Query\n\n' +
7578
'```');
7679
```
7780

81+
**Output:**
82+
![output.markdown example](/img/v2/scripts/output-markdown.png)
83+
7884
### output.table()
7985

8086
Displays data in a formatted table.
@@ -104,6 +110,9 @@ const summary = {
104110
output.table(summary);
105111
```
106112

113+
**Output:**
114+
![output.table example](/img/v2/scripts/output-table.png)
115+
107116
### output.inspect()
108117

109118
Displays an object in an expandable, interactive format for inspection.
@@ -165,6 +174,9 @@ const projectData = {
165174
output.inspect(projectData);
166175
```
167176

177+
**Output:**
178+
![output.inspect example](/img/v2/scripts/output-inspect.png)
179+
168180
### output.clear()
169181

170182
Clears all previous output content.

content/scripts/api-reference/record-query-result.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ The RecordQueryResult object is designed to help you work efficiently with query
2020

2121
## Properties
2222

23-
| Property | Type | Description |
24-
| -------- | ---- | ----------- |
25-
| `records` | `ReadonlyArray<NocoDBRecord>` | Array of NocoDBRecord objects returned by the query |
26-
| `recordIds` | `ReadonlyArray<string>` | Array of record IDs (strings) returned by the query |
27-
| `hasMoreRecords` | `boolean` | Whether there are more records available beyond what was returned |
28-
| `table` | `Table` | Reference to the table from which records were queried |
29-
| `raw_data` | `Array` | The raw underlying data from the API response |
23+
| Property | Type | Description |
24+
|------------------|-------------------------------|-------------------------------------------------------------------|
25+
| `records` | `ReadonlyArray<NocoDBRecord>` | Array of NocoDBRecord objects returned by the query |
26+
| `recordIds` | `ReadonlyArray<string>` | Array of record IDs (strings) returned by the query |
27+
| `hasMoreRecords` | `boolean` | Whether there are more records available beyond what was returned |
28+
| `table` | `Table` | Reference to the table from which records were queried |
29+
| `raw_data` | `Array` | The raw underlying data from the API response |
3030

3131
## Methods
3232

content/scripts/api-reference/record.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Working with NocoDBRecord objects is central to most NocoDB scripts, as they all
1919

2020
## Properties
2121

22-
| Property | Type | Description |
23-
| -------- | ---- | ----------- |
24-
| `id` | `string` | The unique identifier for this record |
25-
| `name` | `string` | The primary display value for this record (derived from display field) |
22+
| Property | Type | Description |
23+
|----------|----------|------------------------------------------------------------------------|
24+
| `id` | `string` | The unique identifier for this record |
25+
| `name` | `string` | The primary display value for this record (derived from display field) |
2626

2727
## Methods
2828

@@ -43,7 +43,7 @@ Retrieves the value of a specific cell in the record.
4343
const projectsTable = base.getTable('Projects');
4444

4545
// Query a specific record
46-
const projectRecord = await projectsTable.selectRecordAsync('rec123456');
46+
const projectRecord = await projectsTable.selectRecordAsync('123');
4747

4848
if (projectRecord) {
4949
// Get cell values using field names
@@ -86,7 +86,7 @@ Gets a cell value formatted as a string, applying appropriate formatting based o
8686
const invoicesTable = base.getTable('Invoices');
8787

8888
// Query a specific record
89-
const invoiceRecord = await invoicesTable.selectRecordAsync('rec123456');
89+
const invoiceRecord = await invoicesTable.selectRecordAsync('123');
9090

9191
if (invoiceRecord) {
9292
// Get formatted string values
@@ -279,7 +279,7 @@ const taskCount = record.getCellValue('Task Count'); // number or null
279279
const tasksTable = base.getTable('Tasks');
280280

281281
// Get a specific record
282-
const taskRecord = await tasksTable.selectRecordAsync('rec123456', {
282+
const taskRecord = await tasksTable.selectRecordAsync('123', {
283283
fields: ['Task Name', 'Description', 'Status', 'Due Date', 'Assigned To', 'Priority']
284284
});
285285

@@ -319,8 +319,8 @@ if (taskRecord) {
319319
const employeesTable = base.getTable('Employees');
320320

321321
// Get two employee records
322-
const employee1 = await employeesTable.selectRecordAsync('rec123456');
323-
const employee2 = await employeesTable.selectRecordAsync('rec789012');
322+
const employee1 = await employeesTable.selectRecordAsync('123');
323+
const employee2 = await employeesTable.selectRecordAsync('456');
324324

325325
if (employee1 && employee2) {
326326
// Compare salary values

content/scripts/api-reference/script-settings.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ output.text(`Processing limit: ${limit}`);
5959

6060
The `input.config()` method accepts a configuration object with the following properties:
6161

62-
| Property | Type | Description |
63-
| -------- | ---- | ----------- |
64-
| `title` | `string` | Title of the script, displayed at the top of the settings form |
65-
| `description` | `string` | Description of what the script does (supports some markdown) |
66-
| `items` | `Array<ConfigItem>` | Array of configuration items for the settings form |
62+
| Property | Type | Description |
63+
|---------------|---------------------|----------------------------------------------------------------|
64+
| `title` | `string` | Title of the script, displayed at the top of the settings form |
65+
| `description` | `string` | Description of what the script does (supports some markdown) |
66+
| `items` | `Array<ConfigItem>` | Array of configuration items for the settings form |
6767

6868
### Configuration Item Types
6969

content/scripts/api-reference/session.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ The `session` object is available in every NocoDB script and provides a way to:
1414

1515
## Properties
1616

17-
| Property | Type | Description |
18-
| -------- | ---- | ----------- |
17+
| Property | Type | Description |
18+
|---------------|----------------|------------------------------------------------------------------------------------|
1919
| `currentUser` | `Collaborator` | A Collaborator object representing the current user running the script (read-only) |
2020

2121
## Usage Examples

0 commit comments

Comments
 (0)