Set
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.
Properties
Methods
add
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
Remove all of the values from a Set.
delete
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
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 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
trueorfalsefor a given value in the Set.- Return Value
Type
Description
Object
The first value that returns
truefor the predicate function or undefined.- Example
- issue.tags.find(function(tag) { return tag.name === 'release'; });
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
nullif the collection is empty.
forEach
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
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
nullif the Set contains fewer than (index + 1) elements.
has
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
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
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
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
nullif collection is empty.
map
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
visitoron each element in insertion order.- Example
- // Collect logins of all permitted users const logins = issue.permittedUsers.map((u) => u.login);
slice
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
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().