YouTrack Standalone 7.0 Help

Issues

The current issue that is changed by the workflow rule is referenced as issue. When you reference an issue in a workflow rule, you can omit the issue and enter the property or method. For example, issue.Assignee = issue.reporter and Assignee = reporter do the same.

Issue Properties

Any property that returns a sequence type has a set of extended properties that are available for all sequence types. There are also operations that you can use to find, add, remove, and clear elements in the sequence. For more information, see Sequences

The following properties are available for issues. Each property is presented in the following format: [property name]: [data type].

PropertyDescriptionState
reporter: UserThe user who reported the issue. For example, Assignee = reporter sets the user who reported the issue as the assignee.Read-only
created: dateThe date when the issue was created.Read-only
updated: dateThe date when the issue was last updated.Read-only
resolved: dateThe date when an issue was set to a value that is considered resolved. When an issue enters a resolved state, the issue.resolved date is set to that moment. When an issue returns to an unresolved state, the property is set to a null value.Read-only
permittedGroup: UserGroupThe user group for which the issue is visible. If the property contains a null value, the issue is visible to the All Users group.Read-only
comments: sequence<IssueComment>A list of comments that have been added to the issue. For comment-related methods, see getEditedComments and addComment. Read-only
attachments: sequence<Attachment>The read-only list of attachments for the issue. See also clearAttachments. Read-only
duplicateCluster: integerThe number of issues that are linked to the current issue with the duplicates link type.Read-only
project: ProjectThe project to which the issue is assigned. See also Project-related Methods.Read/write
summary: stringThe text that is entered as the issue summary.Read/write
description: stringThe text that is entered as the issue description.Read/write
votes: integerThe number of votes for an issue. For vote-related methods, see canVoteIssue, voteIssue, canUnvoteIssue, and unvoteIssue.Read/write
tags: sequence<Issue>The list of tags that are attached to an issue. For tag-related methods, see hasTag, addTag, removeTag, getTag, and getSharedTag.Read/write
numberInProject: integerThe issue number in the project.Read/write
[link type name]: sequence<Issue>The list of issues that are linked to the current issue with the specified link type name. Read/write
[field name]: [field type]The value for the specified custom field. For example, Assignee returns a user, while State returns a state value. If a custom field has an enumerated type, this property returns a sequence.Read/write
sprints: sequence<Sprint>The list of sprints to which an issue is assigned.Read/write

IssueComment Properties

The following properties are available for comments.

PropertyDescriptionState
issue: IssueThe issue to which the comment was added.Read-only
author: UserThe user who entered the comment.Read-only
created: dateThe date when the comment was added to the issue.Read-only
updated: dateThe date when the comment was last updated.Read-only
updatedBy: UserThe user who last updated the comment.Read-only
text: stringThe text that was entered as a comment.Read/write
permittedGroup: UserGroupThe group for which the comment is visible. If permittedGroup == null, the comment is visible to the same group, as the issue it belongs to.Read/write

IssueAttachment Properties

The following properties are available for attachments.

PropertyDescriptionState
issue: IssueThe issue to which the attachment was added.Read-only
author: UserThe user who added the attachment.Read-only
created: dateThe date when the attachment was added to the issue.Read-only
updated: dateThe date when the attachment was last updated.Read-only
name: stringThe filename of the attachment.Read-only
size: longThe size of the attachment in bytes.Read-only
extension: stringThe file extension of the attachment.Read-only
metaData: stringThe metadata properties of the attachment. For example, the dimensions of an image attachment.Read-only
removed: BooleanTrue when the attachment has been removed from the issue.Read-only
permittedGroup: UserGroupThe group for which the attachment is visible. If permittedGroup == null, the attachment is visible to the same group, as the issue it belongs to.Read/write

IssueTag Properties

The following properties are available for tags.

PropertyDescriptionState
name: stringThe name of the tag.Read-only
owner: UserThe user who is the owner of the tag.Read-only

Issue-related Methods

Changes that are applied to issue are managed by a series of transactions. A transaction is a collection of current changes that are either saved to the database or discarded as a set. When a user edits an issue, a new transaction is started. The transaction is completed when the user clicks the Submit button. The single transaction includes all of the changes that were made to the issue.

Rules that are not executed according to a schedule are processed at the end of a transaction. Scheduled rules and scheduled blocks in state-machine rules are only processed for issues that are already reported or become reported in the current transaction.

The following methods are available for use with issues. The syntax for each method is presented in the following format: [method](parameter: [data type]): [data type].

getId

SyntaxgetId(): string
DescriptionReturns the issue ID.
Example
user.notify("Issue is overdue", "Please, look at the issue: " + issue.getId());

getUrl

SyntaxgetUrl(): string
DescriptionReturns the issue URL.
Example
user.notify("Issue is overdue", "Please, look at the issue: " + issue.getUrl());

createCopy

SyntaxcreateCopy(): Issue
DescriptionClones the current issue.

applyCommand

SyntaxapplyCommand(command: string, runAs: user): void
ParameterscommandThe command that is applied to the issue.
runAsSpecifies the user by which the command is applied. If this parameter is not set, the command is applied on behalf of the current user.
DescriptionApplies a command to an issue.
Example
applyCommand("for me Critical")

getEditedComments

SyntaxgetEditedComments(): sequence<IssueComment>
DescriptionGets the comments that are edited in the current transaction. Comments that are added and removed are not considered as edited. These values are represented by the issue.comments.added and issue.comments.removed properties.

addComment

SyntaxaddComment(text: string): IssueComment
ParameterstextThe text to add to the issue as a comment.
DescriptionAdds a comment to the current issue. Sets the issue.comments.changed property to true for the current transaction.
Example
addComment("+1!!!");

clearAttachments

SyntaxclearAttachments(): void
DescriptionRemove all of the attachments from an issue.

hasTag

SyntaxhasTag(name: string): Boolean
ParametersnameThe name of the tag to check for an the issue.
DescriptionChecks whether the specified tag is attached to an issue.
Example
hasTag("todo");

isStarred

SyntaxisStarred(): Boolean
DescriptionChecks whether any user has added the star tag to an issue.

addTag

SyntaxaddTag(name: string): IssueTag
ParametersnameThe name of the tag to attach to the issue.
DescriptionAdd a tag with the specified name to an issue. If the tag does not exist, a new private tag is created for the current user. When you add the star tag on behalf of another user, the user is added to the list of watchers.
Example
addTag("todo");

removeTag

SyntaxremoveTag(name: string): IssueTag
ParametersnameThe name of the tag to remove from the issue.
DescriptionRemove a tag with the specified name from an issue. If the specified tag is not attached to the issue, an exception is thrown. When you remove the star tag on behalf of another user, the user is removed from the list of watchers.
Example
removeTag("waiting for reply");

getDuplicateRoot

SyntaxgetDuplicateRoot(): Issue
DescriptionReturns the root issue in a tree of duplicates that are linked to the current issue.
Example
when issue.duplicateCluster.changed || issue.duplicates.changed || issue.is duplicated by.changed { info("Processing duplicate-cluster issue " + issue.getId()); var duplicateRoot = issue.getDuplicateRoot(); if (duplicateRoot != null) { issue.duplicates.clear; if (issue != duplicateRoot) { issue.duplicates.add(duplicateRoot); duplicateRoot.duplicates.clear; } } }

Issue Lifecycle Methods

The following methods are related to the lifecycle of an issue. The lifecycle of an issue consists of the following stages:

StageDescription
1. Issue is created in this transactionThe issue is still in draft form and does not have an issue ID. The default custom field values are set in this stage.

Rules are not triggered during this stage.

2. Issue is draftChanges are made after creation but before the issue is reported. This stage includes all edits to the draft issue. Stateless and state-machine rules can be triggered during this stage. Scheduled rules and scheduled blocks in state-machine rules are not processed.
3. Issue becomes reported in this transactionThe issue becomes reported. The issue is submitted and is assigned an ID. All rules including scheduled rules and scheduled blocks in state-machine rules are processed during this stage.
4. Issue is reportedThis stage includes all changes made to an issue after it has been reported. All rules including scheduled rules and scheduled blocks in state-machine rules are processed during this stage.
5. Issue is deleted in this transactionThe issue is deleted and is not available after this transaction is complete.

Rules are not triggered during this stage.

isReported

SyntaxisReported(): Boolean
DescriptionChecks whether an issue is already reported or becomes reported in this transaction (stages 3 and 4). To apply changes to an issue draft (stage 2), use !isReported().
Example
for each dep in depends on { if (dep.isReported()) { assert dep.State.isResolved: l10n ( The issue has unresolved dependencies and thus cannot be set Fixed! ); } }

becomesReported

SyntaxbecomesReported(): Boolean
DescriptionChecks whether an issue becomes reported in this transaction (stage 3).
Example
when Assignee == null && (((Subsystem.changed || project.changed) && isReported()) || becomesReported()) { if (issue.Subsystem != null) { issue.Assignee = issue.Subsystem.owner; } }

The following methods are related to the issue.resolved property. This property is set based on the values that are stored in a custom field with a state data type. Each value that can be stored in this field has a Resolved property. This property determines whether the issue is considered to be resolved when it assigned a value for this field.

The resolved property is associated with the issue, which means that these methods do not contain references to the custom field.

isResolved

SyntaxisResolved(): Boolean
DescriptionChecks whether an issue is assigned a state that is considered resolved.
Example
when isResolved() { assert !votes.changed: l10n ( Voting for a resolved issue is not allowed. ); }

becomesResolved

SyntaxbecomesResolved(): Boolean
DescriptionChecks whether an issue is assigned a state that is considered resolved in the current transaction.
Example
when issue.isReported() && issue.becomesResolved() && issue.subtask of.isNotEmpty { var parent = issue.subtask of.first; while (parent != null && !parent.isResolved()){ var allSubtasksResolved = true; for each subtask in parent.parent for { if (!subtask.State.isResolved) { allSubtasksResolved = false; break; } } if (allSubtasksResolved) { parent.State = {Done}; message(l10n ( Automatically set{parent.getId()} as Done)); } parent = parent.subtask of.first; } }

becomesUnresolved

SyntaxbecomesUnresolved(): Boolean
DescriptionChecks whether an issue is assigned a state that is considered unresolved in the current transaction.
Example
when issue.becomesUnresolved() && issue.subtask of.isNotEmpty { var parent = issue.subtask of.first; while (parent != null && !(parent.project.isArchived()) && parent.isResolved()) { parent.State = {Open}; if (parent.Type != null) { message(l10n ( Automatically reopen {parent.Type} {parent.getId()} )); } else { message(l10n ( Automatically reopen {parent.getId()} )); } parent = parent.subtask of.first; } }

Notification-related Methods

These methods can be used to send notifications to unregistered users with an email address. To send notifications to existing users, use the following methods:

MethodDescription
Sends an email notification to the email address that is set in the user profile.
Sends a notification message over Jabber.
Sends an email notification to all of the users who are members of the group.

getNotificationEmail

SyntaxgetNotificationEmail(): String
DescriptionReturns the email address that is used to send notifications for the project. If a From address is not set for the project, the From address for the YouTrack server is returned.
Example
when issue.becomesReported() { if (Last message related emails.isNotEmpty) { for each email in Last message related emails.split(" ", preserveAllTokens) { if (email.isNotBlank && !(email.eq(getNotificationEmail(), ignoreCase))) { if (All related emails.isEmpty) { All related emails = email; } else if (!(All related emails.split(" ", preserveAllTokens).contains(email))) { All related emails = All related emails + " " + email; } } } Last message related emails = null; } }

sendMail

SyntaxsendMail(fromPersonal: String, fromEmail: String, email: String, cc: String, subject: String, body: String)
ParametersfromPersonalThe sender of the email message. If this parameter is not set, the project From address is used. If a From address is not set for the project, the From address for the YouTrack server is used.
fromEmail
emailThe email address of the primary recipient.
ccThe email addresses of additional recipients who receive a copy of the message. Multiple email addresses are delimited with commas. If this parameter is not set, the message is sent to a single recipient.
subjectThe subject line of the email message
bodyThe email message text.
DescriptionSends an email message with the specified parameters.
Example
when comments.added.isNotEmpty { if (Reporter email != null) { sendMail(Reporter email, "[YouTrack, Commented]", "New comment was added: " + comments.added.first.text)); } }

wikify

Syntaxwikify(text: string): string
ParameterstextThe string of text to convert to HTML.
DescriptionConverts text with wiki markup to HTML. Use this method to send "pretty" notifications to unregistered users.
Example
when comments.added.isNotEmpty { for each comment in comments.added { sendMail("myuser@example.com", "Issue is commented", wikify(comment.text)); } }
Last modified: 2 February 2017