# Fields

Represents the custom fields that are used in an issue. The actual set of custom fields that are used for each issue is configured on a per-project basis. The properties shown here correspond with the default custom fields in YouTrack. Additional custom fields that have been attached to a project are also available.

## Methods

### becomes

```JAVASCRIPT
static becomes(field, expected)
```

Checks whether the value for a custom field is set to an expected value in the current transaction.

Parameters
: | Name | Type | Description |
: | --- | --- | --- |
: | field |  string, [ProjectCustomField](v1-ProjectCustomField.html)  |  The field to check.                     |
: | expected |  Object  |  The expected value.                     |

Return Value
: | Type | Description |
: | --- | --- |
: |  boolean  |  If the field is set to the expected value, returns `true`.                 |

### canBeReadBy

```JAVASCRIPT
static canBeReadBy(field, user)
```

Checks whether a user has permission to read the custom field.

Parameters
: | Name | Type | Description |
: | --- | --- | --- |
: | field |  string, [ProjectCustomField](v1-ProjectCustomField.html)  |  The custom field to check for read access.                     |
: | user |  [User](v1-User.html)  |  The user for whom the permission to read the custom field is checked.                     |

Return Value
: | Type | Description |
: | --- | --- |
: |  boolean  |  If the user can read the field, returns `true`.                 |

### canBeWrittenBy

```JAVASCRIPT
static canBeWrittenBy(field, user)
```

Checks whether a user has permission to update the custom field.

Parameters
: | Name | Type | Description |
: | --- | --- | --- |
: | field |  string, [ProjectCustomField](v1-ProjectCustomField.html)  |  The custom field to check for update access.                     |
: | user |  [User](v1-User.html)  |  The user for whom the permission to update the custom field is checked.                     |

Return Value
: | Type | Description |
: | --- | --- |
: |  boolean  |  If the user can update the field, returns `true`.                 |

### isChanged

```JAVASCRIPT
static isChanged(field)
```

Checks whether the custom field is changed in the current transaction.

Parameters
: | Name | Type | Description |
: | --- | --- | --- |
: | field |  string, [ProjectCustomField](v1-ProjectCustomField.html)  |  The name of the custom field (for example, &apos;State&apos;) or a reference to the field that is checked.                     |

Return Value
: | Type | Description |
: | --- | --- |
: |  boolean  |  If the value of the field is changed in the current transaction, returns `true`.                 |

### oldValue

```JAVASCRIPT
static oldValue(field)
```

Returns the previous value of a single-valued custom field before an update was applied. If the field is not changed in the transaction, returns `null`.

Parameters
: | Name | Type | Description |
: | --- | --- | --- |
: | field |  string, [ProjectCustomField](v1-ProjectCustomField.html)  |  The name of the custom field (for example, &apos;State&apos;) or a reference to the field for which the previous value is returned.                     |

Return Value
: | Type | Description |
: | --- | --- |
: |  Object  |  If the custom field is changed in the current transaction, the previous value of the field. Otherwise, the current value of the field.                 |

### required

```JAVASCRIPT
static required(fieldName, message)
```

Asserts that a value is set for a custom 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 |  string  |  The name of the custom field to check.                     |
: | message |  string  |  The message that is displayed to the user that describes the field requirement.                     |

## See also

[ProjectCustomField](v1-ProjectCustomField.html) [User](v1-User.html)

