# Collaborator

> Part of the NocoDB documentation (Workflows > Scripts > API Reference). Index of all pages: https://nocodb.com/llms.txt. Any docs page is available as Markdown by adding `.md` to its URL.

URL: https://nocodb.com/docs/workflows/scripts/api-reference/collaborator
Last updated: 2026-10-03

The Collaborator object in NocoDB Scripts holds the ID, name and email of a user who has access to a base.

The `Collaborator` object is a user who has access to a NocoDB base. It holds the identity of the user: the **ID**, **name**, and **email address**.

## Overview

Collaborator objects come from these sources in NocoDB Scripts:

* `session.currentUser` returns a Collaborator object for the user who runs the script
* `User fields` in records return Collaborator objects
* `base.activeCollaborators` returns an array of Collaborator objects for the current base
* Field types such as `CreatedBy` and `LastModifiedBy` return Collaborator objects

Use this object in scripts to identify users, track ownership, assign responsibilities, and add logic for specific users.

## Properties

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

**Note:** All Collaborator properties are read-only. You cannot change them.

## Contexts Where Collaborator Objects Appear

### Session Object

The `session.currentUser` property returns a Collaborator object for the user who runs the script:

```javascript
// Get the current user
const currentUser = session.currentUser;

output.text(`Current user: ${currentUser.name || currentUser.email}`);
output.text(`User ID: ${currentUser.id}`);
output.text(`Email: ${currentUser.email}`);
```

### Base Object

The `base.activeCollaborators` property returns an array of all Collaborator objects for the current base:

```javascript
// Get all collaborators for this base
const collaborators = base.activeCollaborators;

output.markdown('# Base Collaborators');
output.text(`Number of collaborators: ${collaborators.length}`);

// List all collaborators
for (const collaborator of collaborators) {
  output.text(`- ${collaborator.name || 'Unnamed'} (${collaborator.email})`);
}
```

Use the `base.getCollaborator()` method to find a specific Collaborator by ID, name, or email:

```javascript
// Find a collaborator by email
const collaborator = base.getCollaborator('john.doe@example.com');

if (collaborator) {
  output.text(`Found collaborator: ${collaborator.name || 'Unnamed'}`);
  output.text(`ID: ${collaborator.id}`);
} else {
  output.text('Collaborator not found.');
}
```

### User Field

For a User field, `getCellValue()` returns a Collaborator object. If multiple selection is enabled, it returns an array of Collaborator objects:

```javascript
// Get a record from the Tasks table
const tasksTable = base.getTable('Tasks');
const taskRecord = await tasksTable.selectRecordAsync('123');

// Get the assigned user (assuming 'Assigned To' is a User field)
const assignedTo = taskRecord.getCellValue('Assigned To');

if (assignedTo) {
  // This is a Collaborator object
  output.text(`Task assigned to: ${assignedTo.name || assignedTo.email}`);
} else {
  output.text('Task is unassigned.');
}

// For a User field that allows multiple users
const reviewers = taskRecord.getCellValue('Reviewers') || [];

if (reviewers.length > 0) {
  output.text('Reviewers:');
  for (const reviewer of reviewers) {
    // Each reviewer is a Collaborator object
    output.text(`- ${reviewer.name || reviewer.email}`);
  }
} else {
  output.text('No reviewers assigned.');
}
```

### Created By and Last Modified By Fields

The `CreatedBy` and `LastModifiedBy` field types return Collaborator objects:

```javascript
// Get a record with system user fields
const recordsTable = base.getTable('Documents');
const document = await recordsTable.selectRecordAsync('123');

// Get the user who created the record
const createdBy = document.getCellValue('Created By');
if (createdBy) {
  output.text(`Created by: ${createdBy.name || createdBy.email}`);
  output.text(`Creation date: ${document.getCellValueAsString('Created Time')}`);
}

// Get the user who last modified the record
const lastModifiedBy = document.getCellValue('Last Modified By');
if (lastModifiedBy) {
  output.text(`Last modified by: ${lastModifiedBy.name || lastModifiedBy.email}`);
  output.text(`Last modified: ${document.getCellValueAsString('Last Modified Time')}`);
}
```

## Working with Collaborator Objects

### Finding a Specific Collaborator

```javascript
// Get all collaborators
const collaborators = base.activeCollaborators;

// Find a collaborator by email (case-insensitive)
function findCollaboratorByEmail(email) {
  const lowerEmail = email.toLowerCase();
  return collaborators.find(collaborator => 
    collaborator.email.toLowerCase() === lowerEmail
  );
}

// Find a collaborator by name (case-insensitive)
function findCollaboratorByName(name) {
  const lowerName = name.toLowerCase();
  return collaborators.find(collaborator => 
    collaborator.name && collaborator.name.toLowerCase().includes(lowerName)
  );
}

// Example usage
const collaborator1 = findCollaboratorByEmail('jane.smith@example.com');
const collaborator2 = findCollaboratorByName('john');

if (collaborator1) {
  output.text(`Found by email: ${collaborator1.name || collaborator1.email}`);
}

if (collaborator2) {
  output.text(`Found by name: ${collaborator2.name || collaborator2.email}`);
}
```

### Checking if Current User Matches a Specific Collaborator

```javascript
// Get the current user
const currentUser = session.currentUser;

// Check if the current user is a specific person
function isUser(emailOrId) {
  if (currentUser.email.toLowerCase() === emailOrId.toLowerCase()) {
    return true;
  }
  
  if (currentUser.id === emailOrId) {
    return true;
  }
  
  return false;
}

// Example usage
if (isUser('admin@example.com')) {
  output.text('You are the admin user.');
  // Show admin-specific content
} else {
  output.text('You are not the admin user.');
  // Show regular user content
}
```

## Best Practices

1. **Check for null names** - Some users have no name. Before you use `collaborator.name`, always check if it is null. Use `collaborator.name || collaborator.email` as a fallback.

2. **Be careful with personal information** - Think about how you show and use collaborator information. Take special care with outputs that other people can see.

3. **Handle missing collaborators** - In User fields, always check if the value is null before you read Collaborator properties.

4. **Consider multi-user fields** - A User field can allow multiple selections. Then the value can be an array of Collaborator objects.

5. **Use IDs for references** - When you update a User field in a record, use the ID of the collaborator as the value. Do not use the full Collaborator object.

## Related

* [Base](/docs/workflows/scripts/api-reference/base)
* [Session](/docs/workflows/scripts/api-reference/session)
* [Field](/docs/workflows/scripts/api-reference/field)
* [Record](/docs/workflows/scripts/api-reference/record)

---

## Related pages

- [Base](https://nocodb.com/docs/workflows/scripts/api-reference/base.md): The base object in NocoDB Scripts gives access to the tables and collaborators of the current base.
- [Cursor](https://nocodb.com/docs/workflows/scripts/api-reference/cursor.md): The cursor object in NocoDB Scripts tells a script which base, table, view and row are active.
- [Table](https://nocodb.com/docs/workflows/scripts/api-reference/table.md): The Table object in NocoDB Scripts represents a table and gives methods to query, create, update, and delete its records.
- [View](https://nocodb.com/docs/workflows/scripts/api-reference/view.md): The View object in NocoDB Scripts represents a view of a table and lets you query its records.
- [Field](https://nocodb.com/docs/workflows/scripts/api-reference/field.md): The Field object in NocoDB Scripts gives access to the configuration of a table column, and the field types and their cell values.
- [RecordQueryResult](https://nocodb.com/docs/workflows/scripts/api-reference/record-query-result.md): The RecordQueryResult object in NocoDB Scripts holds the records from a query and supports pagination.
- [Record](https://nocodb.com/docs/workflows/scripts/api-reference/record.md): The NocoDBRecord object in NocoDB Scripts represents one table row and gives methods to read its cell values.
- [Session](https://nocodb.com/docs/workflows/scripts/api-reference/session.md): The session object in NocoDB Scripts gives information about the user who runs the script.
