---
schema: rendered-html/v1
title: "Set | Developer Portal for YouTrack and Hub Documentation"
source_url: https://www.jetbrains.com/help/youtrack/devportal/v1-Set.html
generated_at: 2026-06-11T15:19:14.881307+00:00
---

Feedback

Thanks for your feedback!

Was this page helpful?

YesNo

Developer Portal for YouTrack and Hub

- Developer Portal
- Apps
- MCP Tools
- YouTrack Workflows
- JavaScript Workflow Quick Start Guide
- Create a Workflow
- Edit a Workflow
- Workflow Rule Types
- Transactions
- Use Cases for Workflows
- Web-based Workflow Editor
- Using an External Code Editor
- Default Workflows
- Custom Workflow Repository
- JavaScript Workflow Reference
- Rule-specific Properties
- Context
- Requirements
- Using the Workflow API
- Building Integrations with Slack
- Using REST API Methods in JavaScript Workflows
- Working with Dates and Times
- Working with Periods
- Localized Workflow Messages
- Troubleshooting Workflows
- Remote Debugger
- YouTrack Workflow API
- Change Log
- date-time
- entities
- AbstractVcsItem
- Agile
- AppGlobalStorage
- Article
- ArticleAttachment
- ArticleComment
- BaseArticle
- BaseArticleAttachment
- BaseArticleComment
- BaseComment
- BaseEntity
- BaseWorkItem
- Build
- BundleElementCondition
- BundleProjectCustomField
- Calendar
- Calendar24x7
- ChangesProcessor
- Channel
- EnumField
- FeedbackForm
- Field
- FieldBasedBundleValuesCondition
- FieldBasedUserValuesCondition
- FieldBasedValuesCondition
- Fields
- Gantt
- GroupProjectCustomField
- Issue
- IssueAttachment
- IssueComment
- IssueLinkPrototype
- IssueTag
- IssueWorkItem
- Iterator
- JsonForArticleAddAttachment
- JsonForArticleAddComment
- JsonForArticleConstructor
- JsonForIssueAddAttachment
- JsonForIssueAddComment
- JsonForIssueAddWorkItem
- JsonForIssueCommentAddAttachment
- JsonForIssueConstructor
- JsonForUserNotify
- MailboxChannel
- OwnedField
- PeriodProjectCustomField
- PersistentFile
- Project
- ProjectCustomField
- ProjectTeam
- ProjectType
- ProjectVersion
- PullRequest
- PullRequestState
- Requirement
- Requirements
- [SavedQuery](jetbrains__com__help__youtrack__devportal__v1-savedquery.md)
- [Set](v1-Set.html)
- [SimpleCalendar](jetbrains__com__help__youtrack__devportal__v1-simplecalendar.md)
- [SimpleProjectCustomField](jetbrains__com__help__youtrack__devportal__v1-simpleprojectcustomfield.md)
- [Sprint](jetbrains__com__help__youtrack__devportal__v1-sprint.md)
- [State](jetbrains__com__help__youtrack__devportal__v1-state.md)
- [Tag](jetbrains__com__help__youtrack__devportal__v1-tag.md)
- [TextProjectCustomField](jetbrains__com__help__youtrack__devportal__v1-textprojectcustomfield.md)
- [User](jetbrains__com__help__youtrack__devportal__v1-user.md)
- [UserAttributes](jetbrains__com__help__youtrack__devportal__v1-userattributes.md)
- [UserCondition](jetbrains__com__help__youtrack__devportal__v1-usercondition.md)
- UserGroup
- UserProjectCustomField
- UserType
- VcsChange
- VcsServer
- WatchFolder
- WorkItemAttributeValue
- WorkItemAttributes
- WorkItemProjectAttribute
- WorkItemType
- http
- license
- notifications
- search
- strings
- workflow
- YouTrack Import Scripts
- YouTrack Form API
- YouTrack REST API
- Hub REST API

1. YouTrack Workflows
2. JavaScript Workflow Reference
3. YouTrack Workflow API
4. entities
5. [Set](#0)

# Set﻿

Last modified: 07 May 2026

The `Set` object stores unique values of any type, whether primitive values or object references. The Set is used as storage for all multi-value objects in this API: custom fields that store multiple values, issue links, issues in a project, and so on. You can access single values in the collection directly (see first(), last(), get(index)), use an iterator (see entries(), values()), or traverse with forEach(visitor) and find(predicate) methods. The workflow API is based on ECMAScript 5.1. This Set implementation mimics the functionality supported by the [ES 6 Set interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).

## Properties﻿

| Name | Type | Description |
| added | Set | The elements that are added to a field that stores multiple values in the current transaction. Only relevant when the Set represents a multi-valued property (field) of a persistent entity. |
| isChanged | boolean | When the Set represents a multi-valued property (field) of a persistent entity and the field is changed in the current transaction, this property is `true`. |
| removed | Set | The elements that are removed from a field that stores multiple values in the current transaction. Only relevant when the Set represents a multi-valued property (field) of a persistent entity. |
| size | number | The number of elements in a Set. Use thoughtfully, as the calculation for large collections (like `project.issues`) may be resource consumptive. |

## Methods﻿

### add﻿

add(element)

Add an element to a Set. If the specified value is already present, a duplicate value is not added.

**Parameters**

| Name | Type | Description |
| element | Object | The element to add to the Set. |

### clear﻿

clear()

Remove all of the values from a Set.

### delete﻿

delete(element)

Remove an element from a Set. If the specified element is not present, nothing happens.

**Parameters**

| Name | Type | Description |
| element | Object | The element to remove from the Set. |

### entries﻿

entries()

Get an iterator for the entries in a Set. The same as `values()`. Use an iterator when you need to traverse over entries until a specific condition is met and modify the entries at the same time.

**Return Value**

| Type | Description |
| --- | --- |
| Iterator.<Object> | An iterator for the collection of values. |

**Example**

// We want to find first Critical among issue subtasks and assign it.
const checkAndAssign = function(task) {
  if (task.fields.Priority.name === ctx.Priority.Critical.name) {
    task.fields.Assignee = ctx.currentUser;
    return true;
  }
  return false;
};
const iter = issue.links['parent for'].entries();
let v = iter.next();
while (!v.done && !checkAndAssign(v.value)) {
  v = iter.next();
}

**See Also**

- If you need to modify all of the elements in the Set, see forEach(visitor).
- If you need to find an element that meets specific criteria, see find(predicate).

### find﻿

find(predicate)

Find the first element in a Set for which a predicate function returns `true`.

**Parameters**

| Name | Type | Description |
| predicate | function | A function with one argument that returns either true or false for a given value in the Set. |

**Return Value**

| Type | Description |
| --- | --- |
| Object | The first value that returns `true` for the predicate function or undefined. |

**Example**

issue.tags.find(function(tag) {
  return tag.name === 'release';
});

### first﻿

first()

Find the first object in a collection based on the order in which the elements were added to the Set.

**Return Value**

| Type | Description |
| --- | --- |
| Object | The first object in a collection or null if the collection is empty. |

### forEach﻿

forEach(visitor)

Apply a visitor function to each member of a collection.

**Parameters**

| Name | Type | Description |
| visitor | function | The function to be applied to each member of the collection. |

**Example**

issue.links['parent for'].forEach(function(child) {
  child.fields.Priority = issue.fields.Priority;
});

### get﻿

get(index)

Find an element with a specific index position in a Set.

**Parameters**

| Name | Type | Description |
| index | number | The ordinal index of the element to be returned from the Set. |

**Return Value**

| Type | Description |
| --- | --- |
| Object | An object at index position in a Set, or null if the Set contains fewer than (index + 1) elements. |

### has﻿

has(element)

Checks a Set object to determine whether the specified element is present in the collection or not.

**Parameters**

| Name | Type | Description |
| element | Object | The element to locate in the Set. |

**Return Value**

| Type | Description |
| --- | --- |
| boolean | If the element is found, returns `true`, otherwise, `false`. |

### isEmpty﻿

isEmpty()

Checks a Set object to determine whether it is empty.

**Return Value**

| Type | Description |
| --- | --- |
| boolean | If the Set is empty, returns `true`, otherwise, `false`. |

### isNotEmpty﻿

isNotEmpty()

Checks a Set object to determine whether it is not empty.

**Return Value**

| Type | Description |
| --- | --- |
| boolean | If the Set is not empty, returns `true`, otherwise, `false`. |

### last﻿

last()

Find the last object in a collection based on the order in which the elements were added to the Set.

**Return Value**

| Type | Description |
| --- | --- |
| Object | The last object in a collection or null if collection is empty. |

### map﻿

map(visitor)

Transform each element in a Set and return the results as an array.

Available since 2025.3

**Parameters**

| Name | Type | Description |
| visitor | function | A function called for each value with arguments `(value, index, set)`. |

**Return Value**

| Type | Description |
| --- | --- |
| Array.<\*> | An array with the results of calling `visitor` on each element in insertion order. |

**Example**

// Collect logins of all permitted users
const logins = issue.permittedUsers.map((u) => u.login);

### slice﻿

slice(start, end)

Create a shallow copy of a portion of a Set as an array.

Available since 2025.3

**Parameters**

| Name | Type | Description |
| start | number | Zero-based index at which to begin extraction. Negative values are treated as 0. |
| end | number | Zero-based index before which to end extraction. If omitted, extracts through the end. |

**Return Value**

| Type | Description |
| --- | --- |
| Array.<Object> | An array containing the extracted values in insertion order. Returns an empty array when the range is empty. |

**Example**

// Get first 3 subtasks
const firstThree = issue.links['parent for'].slice(0, 3);

### values﻿

values()

Get an iterator for the entries in a Set. The same as `entries()`.

**Return Value**

| Type | Description |
| --- | --- |
| Iterator.<Object> | An iterator for the collection of values. |

**See Also**

- For details, see entries().

- [Set](/help/youtrack/devportal/v1-Set.html)
- [Properties](/help/youtrack/devportal/v1-Set.html#properties)
- [Methods](/help/youtrack/devportal/v1-Set.html#methods)
- [add](/help/youtrack/devportal/v1-Set.html#add)
- [clear](/help/youtrack/devportal/v1-Set.html#clear)
- [delete](/help/youtrack/devportal/v1-Set.html#delete)
- [entries](/help/youtrack/devportal/v1-Set.html#entries)
- [find](/help/youtrack/devportal/v1-Set.html#find)
- [first](/help/youtrack/devportal/v1-Set.html#first)
- [forEach](/help/youtrack/devportal/v1-Set.html#forEach)
- [get](/help/youtrack/devportal/v1-Set.html#get)
- [has](/help/youtrack/devportal/v1-Set.html#has)
- [isEmpty](/help/youtrack/devportal/v1-Set.html#isEmpty)
- [isNotEmpty](/help/youtrack/devportal/v1-Set.html#isNotEmpty)
- [last](/help/youtrack/devportal/v1-Set.html#last)
- [map](/help/youtrack/devportal/v1-Set.html#map)
- [slice](/help/youtrack/devportal/v1-Set.html#slice)
- [values](/help/youtrack/devportal/v1-Set.html#values)

[SavedQuery](jetbrains__com__help__youtrack__devportal__v1-savedquery.md)[SimpleCalendar](jetbrains__com__help__youtrack__devportal__v1-simplecalendar.md)

- Privacy & Security
- Terms Of Use
- Trademarks
- Legal

Copyright © 2000–2026 JetBrains s.r.o.

![](https://bat.bing.com/action/0?ti=5220035&tm=gtm002&Ver=2&mid=f51b2ffc-08d0-40e9-a22e-eb08fd5d9e61&bo=4&sid=452929b065a111f19a7fe7356f74a419&vid=aa3122f0648711f1a10d6d095e10fd87&vids=0&msclkid=N&pi=918639831&lg=en-US&sw=1920&sh=1080&sc=24&tl=Set%20%7C%20Developer%20Portal%20for%20YouTrack%20and%20Hub%20Documentation&p=https%3A%2F%2Fwww.jetbrains.com%2Fhelp%2Fyoutrack%2Fdevportal%2Fv1-Set.html&r=&lt=969&pt=1781191151650,32,32,,,3,3,3,3,3,,3,28,29,36,219,219,219,967,968,969&pn=0,0&evt=pageLoad&sv=2&asc=G&cdb=AQAS&rn=334581)
