User
Extends: BaseEntity
Represents a user account in YouTrack.
Properties
Name | Type | Description | Read-only |
---|---|---|---|
static current | | The current (logged in) user. | |
static fieldType | | Field type. Used when defining rule requirements. | |
becomesRemoved | | When `true`, the entity is removed in the current transaction. Otherwise, `false`. | |
| The email address of the user. | ||
firstDayOfWeeks | | First day of week as set in the user's profile settings. 0 is for Sunday, 1 is for Monday, etc. | |
fullName | | The full name of the user as seen in their profile. | |
isBanned | | If the user is currently banned, this property is `true`. | |
isNew | | When `true`, the entity is created in the current transaction. Otherwise, `false`. | |
login | | The login of the user. | |
timeZoneId | | User's time zone id. | |
visibleName | | The full name of the user or the login if the full name is not set. |
Methods
findByEmail
static findByEmail(email)
Finds users by email.
Parameters:
Name | Type | Description |
---|---|---|
| The email to search for. |
Returns:
Type | Description |
---|---|
| Users with the specified email. |
findByLogin
static findByLogin(login)
Finds a user by login.
Parameters:
Name | Type | Description |
---|---|---|
login | | The login of the user account to search for. |
Returns:
Type | Description |
---|---|
| The specified user, or null when a user with the specified login is not found. |
findUniqueByEmail
static findUniqueByEmail(email)
Finds a user by email.
Parameters:
Name | Type | Description |
---|---|---|
| The email of the user account to search for. |
Returns:
Type | Description |
---|---|
| The specified user, or null when a user with the specified email is not found or there are multiple users with the specified email. |
becomes
becomes(fieldName, expected)
Checks whether a field is set to an expected value in the current transaction.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field to check. |
expected | | The expected value. |
Returns:
Type | Description |
---|---|
| If the field is set to the expected value, returns `true`. |
canBeReadBy
canBeReadBy(fieldName, user)
Checks whether a user has permission to read the field.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field. |
user | | The user for whom the permission to read the field is checked. |
Returns:
Type | Description |
---|---|
| If the user can read the field, returns `true`. |
canBeWrittenBy
canBeWrittenBy(fieldName, user)
Checks whether a user has permission to update the field.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field. |
user | | The user for whom the permission to update the field is checked. |
Returns:
Type | Description |
---|---|
| If the user can update the field, returns `true`. |
canUnvoteIssue
canUnvoteIssue(issue)
Checks whether the user is able to remove their vote from the specified issue.
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue to check. |
Returns:
Type | Description |
---|---|
| If the user can vote for the issue, returns `true`. |
canVoteIssue
canVoteIssue(issue)
Checks whether the user is able to vote for the specified issue.
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue to check. |
Returns:
Type | Description |
---|---|
| If the user can vote for the issue, returns `true`. |
getSharedTag
getSharedTag(name)
Returns a tag with the specified name that is shared with but not owned by the user. If such a tag does not exist, a null value is returned.
Parameters:
Name | Type | Description |
---|---|---|
name | | The name of the tag. |
Returns:
Type | Description |
---|---|
| The tag. |
getTag
getTag(name, createIfNotExists)
Returns a tag that is visible to the user.
Parameters:
Name | Type | Description |
---|---|---|
name | | The name of the tag. |
createIfNotExists | | If `true` and the specified tag does not exist or is not visible to the user and the user has permission to create tags, a new tag with the specified name is created. |
Returns:
Type | Description |
---|---|
| The tag. |
hasRole
hasRole(roleName, project)
Checks whether the user is granted the specified role in the specified project. When the project parameter is not specified, checks whether the user has the specified role in any project.
Parameters:
Name | Type | Description |
---|---|---|
roleName | | The name of the role to check for. |
project | | The project to check for the specified role assignment. If omitted, checks if the user has the global role. |
Returns:
Type | Description |
---|---|
| If the user is granted the specified role, returns `true`. |
isChanged
isChanged(fieldName)
Checks whether the value of a field is changed in the current transaction.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field to check. |
Returns:
Type | Description |
---|---|
| If the value of the field is changed in the current transaction, returns `true`. |
isInGroup
isInGroup(groupName)
Checks whether the user is a member of the specified group.
Parameters:
Name | Type | Description |
---|---|---|
groupName | | The name of the group to check for. |
Returns:
Type | Description |
---|---|
| If the user is a member of the specified group, returns `true`. |
notify
notify(subject, body, ignoreNotifyOnOwnChangesSetting, project)
Sends an email notification to the email address that is set in the user profile.
Parameters:
Name | Type | Description |
---|---|---|
subject | | The subject line of the email notification. Alternatively, pass a JSON specified by JsonForUserNotify |
body | | The message text of the email notification. |
ignoreNotifyOnOwnChangesSetting | | If `false`, the message is not sent when changes are performed on behalf of the current user. Otherwise, the message is sent anyway. |
project | | When set, the email address that is used as the 'From' address for the specified project is used to send the message. |
oldValue
oldValue(fieldName)
Returns the previous value of a single-value field before an update was applied. If the field is not changedin the transaction, returns null.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field. |
Returns:
Type | Description |
---|---|
| If the field is changed in the current transaction, the previous value of the field.Otherwise, null. |
required
required(fieldName, message)
Asserts that a value is set for a field.If a value for the required field is not set, the specified message is displayed in the user interface.
Parameters:
Name | Type | Description |
---|---|---|
fieldName | | The name of the field to check. |
message | | The message that is displayed to the user that describes the field requirement. |
sendJabber
sendJabber(message)
Sends a notification message over Jabber. Similar to the `notify`method, the message won't be sent on own changes and corresponding flag unchecked.
Parameters:
Name | Type | Description |
---|---|---|
message | | The message text for the Jabber notification. |
sendMail
sendMail(subject, body)
Sends an email notification to the email address that is set in the user profile. An alias for notify(subject, body, true).
Parameters:
Name | Type | Description |
---|---|---|
subject | | The subject line of the email notification. |
body | | The message text of the email notification. |
unvoteIssue
unvoteIssue(issue)
Removes a vote on behalf of the user from the issue, if allowed.
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue from which the vote is removed. |
unwatchIssue
unwatchIssue(issue)
Removes the current user from the list of watchers for the issue(remove `Star` tag).
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue to from which the user is removed as a watcher. |
voteIssue
voteIssue(issue)
Adds a vote on behalf of the user to the issue, if allowed.
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue to which the vote is added. |
watchIssue
watchIssue(issue)
Adds the current user to the issue as a watcher (add `Star` tag).
Parameters:
Name | Type | Description |
---|---|---|
issue | | The issue to which the user is added as a watcher. |