- Issues
- Static methods
- RichIssue properties
- RichIssue methods
- Transition by name
- Silent updates
- Direct methods (without GET)
- Status field guard
- Issue links
- Read custom fields by name
- Worklogs
- Changelog
- Watchers
- Notify options
- SearchResult
- Search options
- Pagination
- Smart field resolution
- Field auto-transform
- ChainablePromise
- Bulk operations
- Next steps
Part of the Scripting API reference. Issues | Jira Entities | Service Management | Utilities | Smart Values
Issues
The Issues namespace provides high-level issue operations with smart field resolution, auto-transformations, and RichIssue objects.
Static methods
| Method | Description | API calls |
|---|---|---|
Issues.get(key, options?) |
Get issue by key. Returns a RichIssue (chainable) | 1 |
Issues.search(jql, options?) |
Search issues by JQL (auto-paginates when maxResults > 100). Returns SearchResult |
1-50 (1 per page) |
Issues.count(jql) |
Count issues matching JQL (approximate count from Jira) | 1 |
Issues.create(project, issueType, fields?) |
Create a new issue, returns a chainable RichIssue | 2 (+1 field cache) |
Issues.update(key, fields, opts?) |
Update issue fields without prior GET (opts: notifyUsers) | 1 |
Issues.transition(key, name, opts?) |
Transition issue without prior GET (opts: fields, comment) | 2 |
Issues.addComment(key, textOrAdf) |
Add comment to issue without prior GET | 1 |
Issues.link(key1, linkType, key2) |
Create an issue link | 1 |
Issues.notify(key, options) |
Send email notification about an issue | 1 |
// Get an issue
const issue = Issues.get("TEST-1")
log(issue.summary)
log(issue.status)
// Search issues
const results = Issues.search("project = TEST AND status = Open", {
maxResults: 10,
fields: ["summary", "status"],
includeTotal: true
})
log(`Found: ${results.total}`)
for (const issue of results.issues) {
log(`${issue.key}: ${issue.summary}`)
}
// Ask for more than one page - Issues.search() paginates for you
const all = Issues.search("project = TEST AND status = Open", {
maxResults: 1000
})
log(`Total: ${all.issues.length}`)
// Count
const count = Issues.count("project = TEST")
// Create an issue
const created = Issues.create("TEST", "Task", {
summary: "New task",
description: "Task description"
})
log(created.key)
// Link issues
Issues.link("TEST-1", "Blocks", "TEST-2")
RichIssue properties
Core properties:
| Property | Description |
|---|---|
key |
Issue key (e.g., "TEST-1") |
id |
Issue ID |
summary |
Summary text |
status |
Status name |
statusCategory |
Status category key: "new", "indeterminate", or "done" |
assignee |
Assignee display name |
assigneeId |
Assignee account ID |
reporter |
Reporter display name |
priority |
Priority name |
issueType |
Issue type name |
project |
Project key |
labels |
Labels array |
components |
Components array (names) |
fixVersions |
Fix versions array (names) |
created |
Created date string |
updated |
Updated date string |
dueDate |
Due date string (e.g. "2024-03-15"), null if not set |
description |
Raw ADF document (use Adf.toText() for plain text) |
parent |
Parent issue key (null if no parent) |
subtasks |
Array of subtask keys |
links |
Array of linked issues - each element is { id, type, direction, key, summary } (see Issue links) |
resolution |
Resolution name (e.g. "Done"), null if unresolved |
self |
REST API URL for this issue |
fields |
Raw fields object |
Computed properties (calculated automatically, no API call):
| Property | Type | Description |
|---|---|---|
age |
number | Days since creation |
staleDays |
number | Days since last update |
isOverdue |
boolean | true if dueDate < now |
isAssigned |
boolean | true if the issue has an assignee |
isResolved |
boolean | Whether in ‘done’ status category |
isInProgress |
boolean | Whether in ‘indeterminate’ status category |
isTodo |
boolean | Whether in ‘new’ status category |
Typed wrapper properties:
| Property | Type | Description |
|---|---|---|
assigneeUser |
User/null | Assignee as User wrapper |
reporterUser |
User | Reporter as User wrapper |
projectObj |
Project | Project as Project wrapper |
RichIssue methods
Each method costs 1 API call unless noted.
| Method | Description | API calls |
|---|---|---|
issue.update(fields, opts?) |
Update issue fields (opts: notifyUsers, see Silent updates) |
1 |
issue.transition(nameOrStatus, options?) |
Transition by transition name or target status | 2 |
issue.addComment(textOrAdf) |
Add a comment (a string auto-converts to ADF) | 1 |
issue.getComments(opts?) |
Get issue comments - all pages unless startAt/maxResults are given |
1+ (paginated) |
issue.getTransitions() |
Get available transitions | 1 |
issue.assign(accountId) |
Assign to a user | 1 |
issue.unassign() |
Remove assignee | 1 |
issue.addWatcher(accountId) |
Add a watcher | 1 |
issue.link(linkType, targetKey) |
Link to another issue | 1 |
issue.addLabel(label) |
Add a label (idempotent) | 1 |
issue.removeLabel(label) |
Remove a label (idempotent) | 1 |
issue.field(nameOrId) |
Read any field by name or ID (with smart resolution) | 0 |
issue.delete() |
Delete the issue | 1 |
issue.reload() |
Reload issue data from Jira | 1 |
issue.clone(overrides?) |
Clone the issue, returns a RichIssue | 2 |
issue.notify(options) |
Send email notification | 1 |
issue.deleteComment(commentId) |
Delete a comment | 1 |
issue.editComment(commentId, textOrAdf) |
Edit a comment | 1 |
issue.getFirstComment() |
Get first (oldest) comment | 1 |
issue.getLastComment() |
Get last (newest) comment | 1 |
issue.takeCommentsFromLatest(n) |
Get n most recent comments | 1 |
issue.takeCommentsFromOldest(n) |
Get first n comments | 1 |
issue.getWatchers() |
Get all watchers (returns User[]) | 1 |
issue.removeWatcher(accountId) |
Remove a watcher | 1 |
issue.getWorklogs() |
Get all work logs | 1 |
issue.addWorklog(timeSpent, opts?) |
Add work log (opts: started, comment) | 1 |
issue.getChangelog(opts?) |
Get change history (opts: maxPages) |
1+ (paginated) |
issue.getAttachments() |
List attachments from the loaded issue (no extra call) | 0 |
issue.deleteAttachment(attachmentId) |
Delete an attachment by ID | 1 |
issue.copyAttachmentsTo(targetKey, opts?) |
Copy attachments to another issue - see Attachments | 1-2 + 2 per file |
issue.getRemoteLinks() |
Get remote (web) links | 1 |
issue.addRemoteLink(url, title, opts?) |
Add a remote link | 1 |
issue.removeRemoteLink(linkId) |
Remove a remote link | 1 |
issue.removeLink(linkId) |
Remove an issue link by ID | 1 |
issue.unlink(linkType, targetKey) |
Remove link by type and target issue | 1 |
issue.addComponent(name) |
Add component to issue (idempotent) | 1 |
issue.removeComponent(name) |
Remove component from issue (idempotent) | 1 |
issue.addFixVersion(name) |
Add fix version (idempotent) | 1 |
issue.removeFixVersion(name) |
Remove fix version (idempotent) | 1 |
issue.getVotes() |
Get vote information | 1 |
issue.addVote() |
Vote for issue | 1 |
issue.removeVote() |
Remove vote | 1 |
issue.listProperties() |
List custom property keys | 1 |
issue.getProperty(propKey) |
Get custom property value | 1 |
issue.setProperty(propKey, value) |
Set custom property | 1 |
issue.deleteProperty(propKey) |
Delete custom property | 1 |
issue.isSubTask() |
Check if issue is a subtask | 0 |
issue.getCreator() |
Get creator as User wrapper | 0 |
issue.getParentObject() |
Get parent as RichIssue | 1 |
issue.getSubTaskObjects() |
Get all subtasks as RichIssue[] | N |
issue.createSubTask(issueType, fields?) |
Create a subtask | 1 |
issue.getCustomFieldValue(nameOrId) |
Get custom field value by name or ID | 0 |
getComments options: { startAt?: number, maxResults?: number } - passing either reads a single page (50 comments per page) instead of all of them. See List methods and pagination.
// Every comment, one API call per 50
const comments = issue.getComments()
// One request only, when the API budget matters
const firstPage = issue.getComments({ startAt: 0, maxResults: 50 })
const issue = Issues.get("TEST-1")
// Update fields
issue.update({ summary: "Updated title", priority: { name: "High" } })
// Transition
issue.transition("Done")
issue.transition("In Progress", { comment: "Starting work" })
// Comments
issue.addComment("Plain text comment")
const comments = issue.getComments()
// Assignment
const user = Users.current()
issue.assign(user.accountId)
issue.unassign()
// Clone with overrides
const copy = issue.clone({ summary: "Copy of " + issue.summary })
// Reload fresh data
issue.reload()
// Comments
const last = issue.getLastComment()
issue.editComment(last.id, "Updated comment text")
issue.deleteComment(last.id)
// Worklogs
issue.addWorklog("2h 30m", { comment: "Code review" })
const logs = issue.getWorklogs()
// Attachments and remote links
const attachments = issue.getAttachments()
issue.addRemoteLink("https://example.com", "Design doc")
const remoteLinks = issue.getRemoteLinks()
// Components and versions
issue.addComponent("Backend")
issue.addFixVersion("v2.0")
issue.removeComponent("Frontend")
// Votes
issue.addVote()
const votes = issue.getVotes()
// Custom properties
issue.setProperty("custom.score", 42)
const score = issue.getProperty("custom.score")
// Subtasks
if (!issue.isSubTask()) {
const sub = issue.createSubTask("Sub-task", { summary: "Implementation" })
const subs = issue.getSubTaskObjects()
}
// Change history
const changelog = issue.getChangelog()
// Static update/transition (without getting issue first)
Issues.update("TEST-1", { summary: "New title" }, { notifyUsers: false })
Issues.transition("TEST-1", "Done", { comment: "Closing" })
Issues.addComment("TEST-1", "A comment via static method")
// Send email notification
issue.notify({
subject: "Action required",
textBody: "Please review this issue",
to: { assignee: true, watchers: true }
})
Transition by name
Find transitions by transition name or target status:
const issue = Issues.get('PROJ-1')
issue.transition('Done') // by transition name
issue.transition('In Progress') // by target status
issue.transition('Done', { comment: 'Fixed!' }) // with comment
If the transition is not found, the error message includes a list of available transitions.
Silent updates
Suppress email notifications when updating issues - useful for bulk operations and migrations:
issue.update({ labels: ['migrated'] }, { notifyUsers: false })
Update options:
| Option | Type | Default | Description |
|---|---|---|---|
notifyUsers |
boolean |
true |
Set to false to suppress email notifications |
Only an explicit false value suppresses notifications. Any other value (or omitting the option) sends notifications as usual.
Direct methods (without GET)
Issues.update(), Issues.transition(), and Issues.addComment() operate directly by issue key - no prior Issues.get() needed. This saves 1 API call per operation.
// Update without GET (1 API call instead of 2)
Issues.update('PROJ-1', { priority: 'Critical' })
// Transition without GET (2 API calls instead of 3)
Issues.transition('PROJ-1', 'Done', { comment: 'Fixed!' })
// Comment without GET (1 API call instead of 2)
Issues.addComment('PROJ-1', 'Reviewed and approved')
Use these when you don’t need to read issue data first - common in bulk operations and event triggers.
Status field guard
Jira silently ignores status in field updates. To prevent confusion, setting status in update() throws an error with a hint:
// This throws: "Cannot set status directly. Use issue.transition('Done') or Issues.transition(key, 'Done') instead."
issue.update({ status: 'Done' })
// Correct way:
issue.transition('Done')
Issue links
The links property returns parsed issue links from the issue’s fields:
const issue = Issues.get('PROJ-1')
for (const link of issue.links) {
log(link.type, link.direction, link.key, link.summary)
// e.g. "Blocks" "outward" "PROJ-2" "Related task"
}
| Property | Description |
|---|---|
id |
Link ID (use with issue.removeLink()) |
type |
Link type name (e.g. “Blocks”) |
direction |
"inward" or "outward" |
key |
Linked issue key |
summary |
Linked issue summary |
// Remove a link
const link = issue.links.find(l => l.key === 'PROJ-2')
if (link) issue.removeLink(link.id)
// Create links
Issues.link('PROJ-1', 'blocks', 'PROJ-2')
issue.link('is blocked by', 'PROJ-3')
Read custom fields by name
Use issue.field(nameOrId) to read any field by its human-readable name or ID:
const issue = Issues.get('PROJ-1')
const points = issue.field('Story Points') // => 5
const sprint = issue.field('Sprint') // => { name: 'Sprint 1', ... }
// Also works with field IDs
const value = issue.field('customfield_10016')
This uses the same field cache as smart field resolution - no extra API calls if the cache is already loaded.
Worklogs
// Read worklogs
const worklogs = issue.getWorklogs()
for (const wl of worklogs) {
log(wl.author, wl.timeSpent, wl.started)
}
// Add worklog
issue.addWorklog('2h 30m')
issue.addWorklog('1h', { comment: 'Investigation', started: '2024-01-10T09:00:00.000+0000' })
// Total time spent
const total = worklogs.reduce((sum, w) => sum + w.timeSpentSeconds, 0)
log('Total time:', Math.round(total / 3600) + 'h')
Each worklog object has: id, author, timeSpent, timeSpentSeconds, started, comment.
Changelog
Get the full change history of an issue:
const history = issue.getChangelog()
for (const entry of history) {
log(entry.author, entry.created)
for (const item of entry.items) {
log(` ${item.field}: ${item.from} -> ${item.to}`)
}
}
// Limit pages for large histories
const recent = issue.getChangelog({ maxPages: 3 }) // max 300 entries
// Status changes only
const statusChanges = history.flatMap(e =>
e.items.filter(i => i.field === 'status').map(i => ({
date: e.created, from: i.from, to: i.to,
}))
)
Each changelog entry has: author (display name), created, items (array of { field, from, to }).
Auto-paginates through all pages (100 entries per page). Use maxPages to limit (default: 10).
Watchers
const watchers = issue.getWatchers()
for (const w of watchers) {
log(w.displayName, w.accountId)
}
issue.addWatcher('user-123')
issue.removeWatcher('user-123')
Notify options
issue.notify(options) and Issues.notify(key, options) send email notifications about an issue via Jira.
| Field | Type | Description |
|---|---|---|
subject |
string |
Email subject (max 255 chars) |
textBody |
string |
Plain text body (max 32KB) |
htmlBody |
string |
HTML body (max 32KB) |
to |
object |
Recipients (see below) |
restrict |
object |
Visibility restrictions (optional) |
Recipients (to):
| Field | Type | Description |
|---|---|---|
to.reporter |
boolean |
Notify issue reporter |
to.assignee |
boolean |
Notify issue assignee |
to.watchers |
boolean |
Notify issue watchers |
to.voters |
boolean |
Notify issue voters |
to.users |
array |
Account IDs or { accountId } objects (max 50) |
to.groups |
array |
Group names or { groupId } / { name } objects (max 50) |
Restrictions (restrict):
| Field | Type | Description |
|---|---|---|
restrict.groups |
array |
Group names or { groupId } / { name } objects |
restrict.permissions |
array |
Permission keys or { key } objects (e.g. "BROWSE") |
// Notify specific users with HTML body
issue.notify({
subject: 'Update available',
htmlBody: '<p>New build is <b>ready</b> for testing</p>',
to: { users: ['user-account-id-1', 'user-account-id-2'] }
})
// Notify reporter via namespace method
Issues.notify('PROJ-1', {
subject: 'Issue resolved',
textBody: 'Your issue has been fixed',
to: { reporter: true }
})
// Restrict who can see the notification
issue.notify({
subject: 'Confidential update',
textBody: 'Internal note',
to: { assignee: true },
restrict: {
groups: ['developers'],
permissions: ['BROWSE']
}
})
SearchResult
Issues.search() returns a SearchResult with utility methods:
| Property / Method | Description |
|---|---|
results.issues |
Array of RichIssue objects |
results.keys |
Array of issue keys |
results.total |
Approximate total matching count (only with includeTotal: true, +1 API call) |
results.hasMore |
true if there are more results |
results.nextPageToken |
Token for next page (if hasMore) |
results.nextPage() |
Load next page (preserves original options) |
results.map(fn) |
Map over issues |
results.filter(fn) |
Filter issues |
results.groupBy(field) |
Group issues by field value |
results.countBy(field) |
Count issues per field value |
results.forEach(fn, opts?) |
Process all issues with auto-pagination and error handling (returns report) |
results.updateAll(fields, opts?) |
Update all issues with the same fields - wraps forEach + update (returns report) |
results.transitionAll(status, opts?) |
Transition all issues - wraps forEach + transition (returns report) |
Search options
| Option | Type | Default | Description |
|---|---|---|---|
fields |
string[] |
all | Fields to return |
maxResults |
number |
100 | Total issues to return. A single Jira page holds 100; ask for more (up to 5000) and Issues.search() pages through them automatically |
nextPageToken |
string |
- | Token for next page |
expand |
string[] |
- | Expand options |
includeTotal |
boolean |
false |
Include an approximate total count (+1 API call) |
There is no separate searchAll() method on Issues - auto-pagination lives inside
Issues.search() and kicks in whenever maxResults exceeds 100. Each loaded page
costs one API call, so keep maxResults close to what you actually need.
const results = Issues.search("project = TEST", { maxResults: 50 })
// Iterate
const keys = results.keys // => ['TEST-1', 'TEST-2', ...]
const summaries = results.map(i => i.summary)
const bugs = results.filter(i => i.issueType === "Bug")
const byStatus = results.groupBy("status") // => { 'Open': [...], 'In Progress': [...] }
const counts = results.countBy("status") // => { 'Open': 5, 'In Progress': 3 }
log('Critical:', results.groupBy('priority')['Critical']?.length ?? 0)
// Pagination
if (results.hasMore) {
const page2 = results.nextPage()
}
Pagination
nextPage() - iterate through pages manually, useful when you need to process each page separately or want to stop early:
let result = Issues.search('project = PROJ', { maxResults: 10 })
let allKeys = [...result.keys]
while (result.hasMore) {
result = result.nextPage()
allKeys.push(...result.keys)
}
log('Total keys:', allKeys.length)
nextPage() preserves all original search options (fields, maxResults, expand). It automatically removes includeTotal to avoid extra API calls on subsequent pages.
Auto-pagination (maxResults > 100) - when maxResults exceeds the Jira API page size (100), Issues.search() fetches multiple pages automatically:
// Fetch up to 500 issues automatically
const result = Issues.search('project = PROJ AND status = Open', {
maxResults: 500,
fields: ['summary', 'status']
})
log(result.issues.length) // up to 500
log(result.hasMore) // true if more results exist beyond 500
// nextPage() continues from where auto-pagination stopped
if (result.hasMore) {
const next = result.nextPage()
}
How it works:
- Makes
ceil(maxResults / 100)requests of 100 issues each - Combines all results into a single SearchResult
- Trims to exactly
maxResultsissues - Hard limit: 50 pages (5000 issues max) for safety - for larger datasets, use
nextPage()orforEach()
Cost: N API calls where N = ceil(maxResults / 100). The per-trigger API call limit serves as the final safeguard.
Smart field resolution
Field names in plain objects are automatically resolved to Jira field IDs:
// 'Story Points' -> 'customfield_10016'
Issues.create("PROJ", "Story", { "Story Points": 5, summary: "My story" })
This works in Issues.create(), issue.update(), and other methods that accept field objects.
Field auto-transform
Common fields are automatically transformed to Jira API format:
| Input | Transformation |
|---|---|
priority: 'High' |
priority: { name: 'High' } |
assignee: 'accountId' |
assignee: { accountId: '...' } |
description: 'text' |
description: { type: 'doc', ... } (ADF) |
labels: 'single' |
labels: ['single'] |
components: 'Backend' |
components: [{ name: 'Backend' }] |
fixVersions: 'v1.0' |
fixVersions: [{ name: 'v1.0' }] |
project: 'PROJ' |
project: { key: 'PROJ' } |
dueDate: '2024-03-15' |
duedate: '2024-03-15' (alias) |
ChainablePromise
Issues.get() and Issues.create() return a chainable promise - methods can be chained before await:
Issues.get("PROJ-1").update({ summary: "New" }).addComment("Updated!")
Issues.create("PROJ", "Bug", { summary: "Login broken" }).link("Blocks", "PROJ-1")
// Create with smart fields and chain issue methods - no intermediate variable
Issues.create('PROJ', 'Bug', {
summary: 'Login broken',
priority: 'Critical',
description: 'Users cannot log in',
'Story Points': 3,
}).assign('user-123').addComment('Created via script')
// Use the result when you need the fields of the created issue
const created = Issues.create('PROJ', 'Bug', { summary: 'Login broken' })
log(created.key) // => PROJ-456
log(created.status) // => Open
issue.clone() also returns a full RichIssue, so you can call methods on the clone (clone.addLabel('cloned'), clone.transition('In Progress')).
Bulk operations
forEach(), updateAll(), and transitionAll() process all issues across pages, with per-issue error handling.
const result = Issues.search('project = PROJ AND status = Open')
// Custom processing, across up to 5 pages
const report = result.forEach((issue) => {
issue.update({ labels: ['processed'] }, { notifyUsers: false })
}, { maxPages: 5 })
log(`Done: ${report.success} ok, ${report.failed} failed`)
// report => { success: 150, failed: 2, errors: [...], pagesProcessed: 3 }
// Update all
const report2 = Issues.search('project = PROJ AND labels = old').updateAll({ labels: ['new'] })
log(report2) // { success: 15, failed: 0, errors: [], pagesProcessed: 2 }
// Transition all
const stale = Issues.search('project = PROJ AND status = Open AND updated < -30d')
const report3 = stale.transitionAll('Done', { comment: 'Auto-closed' })
forEach options:
| Option | Type | Default | Description |
|---|---|---|---|
maxPages |
number |
10 | Max pages to iterate (including the current page) |
Report object (returned by forEach(), updateAll(), and transitionAll()):
| Property | Description |
|---|---|
success |
Number of successfully processed issues |
failed |
Number of failed issues |
errors |
Array of { key, error } objects for failures |
pagesProcessed |
Number of pages processed |
How forEach() works:
- Processes all issues on the current page
- If
hasMoreandpagesProcessed < maxPages, auto-callsnextPage() - Continues until all pages are processed or
maxPagesis reached - Catches errors per issue, never stops on failure
- Returns an aggregated report
Next steps
- Scripting API: Jira Entities - Users, Projects, Fields, Boards, Sprints
- Scripting API: Configuration & Assets - Administration namespaces and JSM Assets
- Scripting API: Utilities - Adf, DateUtils, Arrays, Strings, CSV
- Scripting Examples - Practical scripting examples
