Field

Contains field-related data. Its properties determine how the field is used in Data Studio.

```javascript
const cc = DataStudioApp.createCommunityConnector();
const fields = cc.getFields();

const field1 = fields.newDimension()
                   .setId('field1_id')
                   .setName('Field 1 ID')
                   .setDescription('The first field.')
                   .setType(cc.FieldType.YEAR_MONTH)
                   .setGroup('DATETIME');
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/data-studio/field#getAggregation()` | `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` | Returns the `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getDescription()` | `String` | Returns the description of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getFormula()` | `String` | Returns the formula of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getGroup()` | `String` | Returns the group of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getId()` | `String` | Returns the ID of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getIsReaggregatable()` | `Boolean` | Returns `true` if this field can be reaggregated, `false` otherwise. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getName()` | `String` | Returns the name of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#getType()` | `https://developers.google.com/apps-script/reference/data-studio/field-type` | Returns the `https://developers.google.com/apps-script/reference/data-studio/field-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#isDefault()` | `Boolean` | Returns `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is the default metric or dimension. |
| `https://developers.google.com/apps-script/reference/data-studio/field#isDimension()` | `Boolean` | Returns `true` if this field is a dimension. |
| `https://developers.google.com/apps-script/reference/data-studio/field#isHidden()` | `Boolean` | Returns `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is hidden. |
| `https://developers.google.com/apps-script/reference/data-studio/field#isMetric()` | `Boolean` | Returns `true` if this field is a metric. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setAggregation(AggregationType)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the aggregation type of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setDescription(String)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the description of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setFormula(String)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the formula of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setGroup(String)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the group of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setId(String)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the ID of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setIsHidden(Boolean)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the hidden status of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setIsReaggregatable(Boolean)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the reaggregation-permitted status for a `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setName(String)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the name of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |
| `https://developers.google.com/apps-script/reference/data-studio/field#setType(FieldType)` | `https://developers.google.com/apps-script/reference/data-studio/field#` | Sets the `https://developers.google.com/apps-script/reference/data-studio/field-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`. |

## Detailed documentation

### `getAggregation()`

Returns the `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`. `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` determines
how Data Studio combines similar data into dimensions.

#### Return


`https://developers.google.com/apps-script/reference/data-studio/aggregation-type` --- The aggregationType for this field.

*** ** * ** ***

### `getDescription()`

Returns the description of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Descriptions are short explanations of a field's
purpose.

#### Return


`String` --- The description for this field.

*** ** * ** ***

### `getFormula()`

Returns the formula of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Formulas define a data transformation that Data
Studio runs at query-time.

#### Return


`String` --- The formula for this field.

*** ** * ** ***

### `getGroup()`

Returns the group of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Fields collected into a group are presented together
in the Data Studio UI.

#### Return


`String` --- The group for this field.

*** ** * ** ***

### `getId()`

Returns the ID of this `https://developers.google.com/apps-script/reference/data-studio/field#`. IDs are unique per set of fields and are used in formulas
to refer to fields.

#### Return


`String` --- The ID for this field.

*** ** * ** ***

### `getIsReaggregatable()`

Returns `true` if this field can be reaggregated, `false` otherwise.

#### Return


`Boolean` --- `true` if this field can be reaggregated, `false` otherwise.

*** ** * ** ***

### `getName()`

Returns the name of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Names are shown to the user to distinguish fields.

#### Return


`String` --- The name for this field.

*** ** * ** ***

### `getType()`

Returns the `https://developers.google.com/apps-script/reference/data-studio/field-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`.

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field-type` --- The type for this field.

*** ** * ** ***

### `isDefault()`

Returns `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is the default metric or dimension.

#### Return


`Boolean` --- `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is the default metric or dimension; `false`
otherwise.

*** ** * ** ***

### `isDimension()`

Returns `true` if this field is a dimension.

#### Return


`Boolean` --- `true` if this field is a dimension; returns `false` otherwise.

*** ** * ** ***

### `isHidden()`

Returns `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is hidden. You can use hidden fields in formulas,
but not in charts. You cannot hide fields containing formulas.

#### Return


`Boolean` --- `true` if this `https://developers.google.com/apps-script/reference/data-studio/field#` is hidden; `false` otherwise.

*** ** * ** ***

### `isMetric()`

Returns `true` if this field is a metric.

#### Return


`Boolean` --- `true` if this field is a metric; returns `false` otherwise.

*** ** * ** ***

### `setAggregation(aggregation)`

Sets the aggregation type of this `https://developers.google.com/apps-script/reference/data-studio/field#`. `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` determines how Data
Studio combines similar data into dimensions. This throws an error if called on a metric.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `aggregation` | `https://developers.google.com/apps-script/reference/data-studio/aggregation-type` | The aggregation type to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setDescription(description)`

Sets the description of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Descriptions are short explanations of a field's
purpose.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `description` | `String` | The description to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setFormula(formula)`

Sets the formula of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Formulas define a data transformation that Data Studio
runs at query-time.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `formula` | `String` | The formula to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setGroup(group)`

Sets the group of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Fields collected into a group are presented together in
the Data Studio UI.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `group` | `String` | The group to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setId(id)`

Sets the ID of this `https://developers.google.com/apps-script/reference/data-studio/field#`. IDs are unique per set of fields and are used in formulas to
refer to fields.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `id` | `String` | The ID to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setIsHidden(isHidden)`

Sets the hidden status of this `https://developers.google.com/apps-script/reference/data-studio/field#`. You can use hidden fields in formulas, but not in
charts. You cannot hide fields containing formulas.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `isHidden` | `Boolean` | The hidden status to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setIsReaggregatable(isReaggregatable)`

Sets the reaggregation-permitted status for a `https://developers.google.com/apps-script/reference/data-studio/field#`. Attempting to set an aggregation
type on a field that can't be reaggregated results in an error.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `isReaggregatable` | `Boolean` | The reaggregation-permitted status to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setName(name)`

Sets the name of this `https://developers.google.com/apps-script/reference/data-studio/field#`. Names are shown to the user to distinguish fields.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `name` | `String` | The name to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.

*** ** * ** ***

### `setType(type)`

Sets the `https://developers.google.com/apps-script/reference/data-studio/field-type` of this `https://developers.google.com/apps-script/reference/data-studio/field#`.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `type` | `https://developers.google.com/apps-script/reference/data-studio/field-type` | The type to set. |

#### Return


`https://developers.google.com/apps-script/reference/data-studio/field#` --- This builder, for chaining.