Class Field

Field

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

var cc = DataStudioApp.createCommunityConnector();
var fields = cc.getFields();
var types = cc.FieldType;

var field1 = fields.newDimension()
  .setId('field1_id')
  .setName('Field 1 ID')
  .setDescription('The first field.')
  .setType(types.YEAR_MONTH)
  .setGroup('DATETIME');

Methods

MethodReturn typeBrief description
getAggregation()AggregationTypeReturns the AggregationType of this Field.
getDescription()StringReturns the description of this Field.
getFormula()StringReturns the formula of this Field.
getGroup()StringReturns the group of this Field.
getId()StringReturns the ID of this Field.
getName()StringReturns the name of this Field.
getType()FieldTypeReturns the FieldType of this Field.
isDefault()BooleanReturns true if this Field is the default metric or dimension.
isDimension()BooleanReturns true if this field is a dimension.
isHidden()BooleanReturns true if this Field is hidden.
isMetric()BooleanReturns true if this field is a metric.
setAggregation(aggregation)FieldSets the aggregation type of this Field.
setDescription(description)FieldSets the description of this Field.
setFormula(formula)FieldSets the formula of this Field.
setGroup(group)FieldSets the group of this Field.
setId(id)FieldSets the ID of this Field.
setIsHidden(isHidden)FieldSets the hidden status of this Field.
setName(name)FieldSets the name of this Field.
setType(type)FieldSets the FieldType of this Field.

Detailed documentation

getAggregation()

Returns the AggregationType of this Field. AggregationType determines how Data Studio combines similar data into dimensions.

Return

AggregationType — The aggregationType for this field.


getDescription()

Returns the description of this Field. Descriptions are short explanations of a field's purpose.

Return

String — The description for this field.


getFormula()

Returns the formula of this 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 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 Field. IDs are unique per set of fields and are used in formulas to refer to fields.

Return

String — The ID for this field.


getName()

Returns the name of this Field. Names are shown to the user to distinguish fields.

Return

String — The name for this field.


getType()

Returns the FieldType of this Field.

Return

FieldType — The type for this field.


isDefault()

Returns true if this Field is the default metric or dimension.

Return

Booleantrue if this Field is the default metric or dimension; false otherwise.


isDimension()

Returns true if this field is a dimension.

Return

Booleantrue if this field is a dimension; returns false otherwise.


isHidden()

Returns true if this Field is hidden. Hidden fields can be used in formulas, but cannot be used in charts.

Return

Booleantrue if this Field is hidden; false otherwise.


isMetric()

Returns true if this field is a metric.

Return

Booleantrue if this field is a metric; returns false otherwise.


setAggregation(aggregation)

Sets the aggregation type of this Field. AggregationType determines how Data Studio combines similar data into dimensions. This throws an error if called on a metric.

Parameters

NameTypeDescription
aggregationAggregationTypeThe aggregation type to set.

Return

Field — This builder, for chaining.


setDescription(description)

Sets the description of this Field. Descriptions are short explanations of a field's purpose.

Parameters

NameTypeDescription
descriptionStringThe description to set.

Return

Field — This builder, for chaining.


setFormula(formula)

Sets the formula of this Field. Formulas define a data transformation that Data Studio runs at query-time.

Parameters

NameTypeDescription
formulaStringThe formula to set.

Return

Field — This builder, for chaining.


setGroup(group)

Sets the group of this Field. Fields collected into a group are presented together in the Data Studio UI.

Parameters

NameTypeDescription
groupStringThe group to set.

Return

Field — This builder, for chaining.


setId(id)

Sets the ID of this Field. IDs are unique per set of fields and are used in formulas to refer to fields.

Parameters

NameTypeDescription
idStringThe ID to set.

Return

Field — This builder, for chaining.


setIsHidden(isHidden)

Sets the hidden status of this Field. Hidden fields can be used in formulas, but cannot be used in charts.

Parameters

NameTypeDescription
isHiddenBooleanThe hidden status to set.

Return

Field — This builder, for chaining.


setName(name)

Sets the name of this Field. Names are shown to the user to distinguish fields.

Parameters

NameTypeDescription
nameStringThe name to set.

Return

Field — This builder, for chaining.


setType(type)

Sets the FieldType of this Field.

Parameters

NameTypeDescription
typeFieldTypeThe type to set.

Return

Field — This builder, for chaining.

Send feedback about...

Apps Script
Apps Script
Need help? Visit our support page.