Data Functions

A set of convenient functions for working with and manipulating various types of data values.


Array

Array( length, defaultValue? ) -> Array

Since version 1.12

Returns a new array of a given length.

Name Type Description
length Number The desired length for the new array.
defaultValue * optional The value for each element in the array. If no value is specified, the default will be null.

Returns: Array

Example

Returns [null, null, null, null, null].

Array(5)

Returns [1,1,1].

Array(3, 1)

Attachments

Attachments( feature, options? ) -> Attachment[]

Since version 1.6

Profiles: Field Calculate | Attribute Rules | Popup | Feature Reduction Popup | Tasks

Returns a list of attachments associated with the input feature. Each result includes the name of the attachment, the content type, id, and size in bytes.

Name Type Description
feature Feature Attachments associated with this feature will be fetched from the service.
options Dictionary optional Optional settings for the request. See the table below for available options:

OptionTypeDescription
typesText[]An array of stings representing the file types to fetch. The following are supported values: bmp, ecw, emf, eps, ps, gif, img, jp2, jpc, j2k, jpf, jpg, jpeg, jpe, png, psd, raw, sid, tif, tiff, wmf, wps, avi, mpg, mpe, mpeg, mov, wmv, aif, mid, rmi, mp2, mp3, mp4, pma, mpv2, qt, ra, ram, wav, wma, doc, docx, dot, xls, xlsx, xlt, pdf, ppt, pptx, txt, zip, 7z, gz, gtar, tar, tgz, vrml, gml, json, xml, mdb, geodatabase
minsizeNumberThe minimum file size of the attachment in bytes.
maxsizeNumberThe maximum file size of the attachment in bytes.

Returns: Attachment[]

Example

Returns the number of attachments associated with the feature

// Returns the number of attachments associated with the feature
Count(Attachments($feature))

Back

Back( inputArray ) -> *

Since version 1.12

Returns the last element of an array. If the array is empty, then Back(array) will cause the script evaluation to fail.

Name Type Description
inputArray Array The array to get the last value from.

Returns: *

Example

Returns 'gray'.

var colors = ['orange', 'purple', 'gray']
Back(colors)

Console

Console( message [,obj,text, ...objN,textN] ) -> Null

Logs a message in the messages window for debugging purposes. This function can be especially useful for inspecting variable values within a custom function at runtime. Unlike other functions and the return statement, Console() doesn't actually return a value; rather, it logs messages in a separate window for inspection purposes only. The successful use of this function has no computational impact on the evaluation of the expression.

Name Type Description
message [,obj,text, ...objN,textN] * A list of variables, messages, or objects to output in the messages window.

Returns: Null

Example

Prints the value of max for each iteration of the loop within the function

// The messages window will log the following:
// 'current item is: 10, but max = 10'
// 'current item is: 0, but max = 10'
// 'current item is: 84, but max = 84'
// 'current item is: 30, but max = 84'

// The expression evaluates to 84
function findMax(yourArray) {
  var max = -Infinity;
  for (var i in yourArray) {
    max = IIf(yourArray[i] > max, yourArray[i], max);
    Console('current item is: ' + i + ', but max = ' + max);
  }
  return max;
}
var myArray = [ 10, 0, 84, 30];
findMax(myArray);

Count

Count( values ) -> Number

Returns the number of items in an array or FeatureSet, or the number of characters in a string.

Name Type Description
values Array | Text | FeatureSet An array or string on which to perform the operation. In profiles that support accessing data, this can be a FeatureSet.

Returns: Number

Example

Returns 6

Count([12,21,32,44,58,63])

Returns 13

Count('Graham County')

Returns the number of features in a layer

Count($layer)

Dictionary

This function has 2 signatures:

Dictionary( name1?, value1?, [...nameN, compareN]? ) -> Dictionary

Returns a new dictionary based on the provided arguments. The arguments are name/value pairs. e.g. dictionary('field1',val,'field2',val2,...).

Name Type Description
name1 Text optional The attribute name.
value1 * optional The attribute value to pair to name1.
[...nameN, compareN] * optional Ongoing name/value pairs.

Returns: Dictionary

Example

prints 3

var d = Dictionary('field1', 1, 'field2', 2)
return d.field1 + d.field2

Dictionary( json? ) -> Dictionary

Since version 1.8

Returns a new dictionary from stringified JSON.

Name Type Description
json Text optional The stringified JSON to convert to an Arcade dictionary.

Returns: Dictionary

Example

Creates a dictionary from stringified JSON

var extraInfo = '{"id": 1, "population": 200, "city": "Spencer, ID"}'
var spencerIDdata = Dictionary(extraInfo)
spencerIDdata.population // Returns 200

Distinct

This function has 2 signatures:

Distinct( values ) -> Array

Since version 1.1

Returns a set of distinct, or unique, values for a given array or list of values.

Name Type Description
values Array An array or list of values on which to perform the operation.

Returns: Array

Example

Distinct([1,1,2,1,1,2,2,3,4,5])
// Returns [1,2,3,4,5]
Distinct('high','medium','low',0,'high','high','low')
// Returns ['high','medium','low',0]

Distinct( featureset, fields ) -> FeatureSet

Since version 1.8

Profiles: Attribute Rules | Dashboard Data | Field Calculate | Popup | Feature Reduction Popup | Tasks

Returns a set of distinct, or unique, values from a FeatureSet.

Name Type Description
featureset FeatureSet A FeatureSet from which to return distinct values.
fields Text | Array | Object The field(s) and/or expression(s) from which to determine unique values. This parameter can be an array of field names, an array of expressions, or an object or array of objects that specify output column names where unique values will be stored. If an object is specified, the specification in the following table must be used.

PropertyDescription
nameThe name of the column to store the result of the given expression.
expressionA SQL-92 expression from which to calculate a unique value.

Returns: FeatureSet

Example

Returns a FeatureSet with a 'Status' column. Each row of the FeatureSet contains a unique stats value

Distinct($layer, 'Status')

Returns a FeatureSet with a 'Status' and a 'Type' column. Each row of the FeatureSet contains a unique combination of 'Status' and 'Type' values

Distinct($layer, ['Status', 'Type'])

Returns FeatureSet with a Density column with rows that may contain values of Low, High, or N/A

Distinct($layer, {name:'Density', expression:"CASE WHEN PopDensity < 100 THEN 'Low' WHEN PopDensity >= 100 THEN 'High' ELSE 'N/A' END" })

Returns FeatureSet with a Score and a Type column

Distinct($layer, [
  { name: 'Score', expression: 'POPULATION_DENSITY * 0.65 + Status_Code * 0.35' }
  { name: 'Type', expression: 'Category' }
])

Domain

This function has 2 signatures:

Domain( feature, fieldName ) -> Dictionary

Since version 1.11

Returns the domain assigned to the given field of the provided feature. If the feature belongs to a class with a subtype, this returns the domain assigned to the subtype.

Name Type Description
feature Feature The Feature with a field that has a domain.
fieldName Text The name of the field (not the alias of the field) assigned the domain.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
type Text The type of domain - either codedValue or range.
name Text The domain name.
dataType Text The data type of the domain field. It can be one of the following values: esriFieldTypeSmallInteger, esriFieldTypeInteger, esriFieldTypeSingle, esriFieldTypeDouble, esriFieldTypeString, esriFieldTypeDate, esriFieldTypeOID, esriFieldTypeGeometry, esriFieldTypeBlob, esriFieldTypeRaster, esriFieldTypeGUID, esriFieldTypeGlobalID, esriFieldTypeXML.
min Number Only applicable to range domains. The minimum value of the domain.
max Number Only applicable to range domains. The maximum value of the domain.
codedValues Dictionary[] Only applicable to codedValue domains. An array of dictionaries describing the valid values for the field. Each dictionary has a code property, which contains the actual field value, and a name property containing a user-friendly description of the value (e.g. { code: 1, name: "pavement" }).

Example

The domain assigned to the feature's subtype

var d = Domain($feature, "poleType")
// the poleType field has a coded value domain called poleTypes
// the value of d will be
// {
//   type: "codedValue" ,
//   name: "poleTypes",
//   dataType: "number",
//   codedValues: [
//     { name: "Unknown", code: 0 },
//     { name: "Wood", code: 1 },
//     { name: "Steel", code: 2 }
//   ]
// }

Domain( featureSet, fieldName, subtype? ) -> Dictionary

Since version 1.11

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Returns the domain assigned to the given field of the provided featureSet. If the featureSet belongs to a class with a subtype, this returns the domain assigned to the subtype.

Name Type Description
featureSet FeatureSet The FeatureSet whose features contain a field that has a domain.
fieldName Text The name of the field (not the alias of the field) containing the domain.
subtype Text | Number optional The coded value for the subtype if the feature supports subtypes.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
type Text The type of domain - either codedValue or range.
name Text The domain name.
dataType Text The data type of the domain field. It can be one of the following values: esriFieldTypeSmallInteger, esriFieldTypeInteger, esriFieldTypeSingle, esriFieldTypeDouble, esriFieldTypeString, esriFieldTypeDate, esriFieldTypeOID, esriFieldTypeGeometry, esriFieldTypeBlob, esriFieldTypeRaster, esriFieldTypeGUID, esriFieldTypeGlobalID, esriFieldTypeXML.
min Number Only applicable to range domains. The minimum value of the domain.
max Number Only applicable to range domains. The maximum value of the domain.
codedValues Dictionary[] Only applicable to codedValue domains. An array of dictionaries describing the valid values for the field. Each dictionary has a code property, which contains the actual field value, and a name property containing a user-friendly description of the value (e.g. { code: 1, name: "pavement" }).

Example

The domain assigned to the feature's subtype

var fsPole = FeatureSetByName($datastore, "Pole", 1);
var d = Domain(fsPole, "poleType")
// the poleType field has a coded value domain called poleTypes
// the value of d will be
// {
//   type: "codedValue" ,
//   name: "poleTypesThreePhase",
//   dataType: "number",
//   codedValues: [
//     { name: "Unknown", code: 0 },
//     { name: "Wood", code: 1 },
//     { name: "Steel", code: 2 }
//     { name: "Reinforced Steel", code: 3 }
//   ]
// }

DomainCode

DomainCode( feature, fieldName, value, subtype ) -> Text

Since version 1.7

Returns the code of an associated domain description in a feature.

Name Type Description
feature Feature | FeatureSet The feature with a field that has a domain. In profiles that support accessing data, this can be a FeatureSet.
fieldName Text The name of the field (not the alias of the field) containing the domain.
value Text The value to be converted back into a code. This parameter is required when a FeatureSet is passed to the feature parameter. The returned code comes from the service metadata.
subtype Text The coded number for the subtype if the feature supports subtyping. If not provided, the current feature's subtype (if it has one), will be used.

Returns: Text

Example

prints the domain description for the field referenced.

DomainCode($feature, 'Enabled', 'True')

DomainName

DomainName( feature, fieldName, code, subtype? ) -> Text

Since version 1.7

Returns the descriptive name for a domain code in a feature.

Name Type Description
feature Feature | FeatureSet The feature with a field that has a domain. In profiles that support accessing data, this can be a FeatureSet.
fieldName Text The name of the field (not the alias of the field) containing the domain.
code Text The code associated with the desired descriptive name. If not provided, the field value in the feature will be returned. This parameter is required when a FeatureSet is passed to the feature parameter. The returned code comes from the service metadata.
subtype Text optional The coded number of the subtype if the feature supports subtyping. If not provided, the feature's subtype (if it has one) will be used.

Returns: Text

Example

prints the domain description for the referenced field

DomainName($feature, 'fieldName')

Erase

Erase( inputArray, index )

Since version 1.12

Removes a value from an array at a given index. Existing elements positioned at or above the given index will shift down one index value. The array decreases in size by one.

Name Type Description
inputArray Array The array to remove the value from.
index Number The index of the value to remove from the array. If a negative index is provided, it will be used as an offset from the end of the array.

Example

var colors = ['orange', 'purple', 'gray']
Erase(colors, 1)
// colors = ['orange','gray']
var colors = ['orange', 'purple', 'gray']
Erase(colors, -1)
// colors = ['orange','purple']

Expects

Expects( feature, ...field1, field2 ) -> Null

Since version 1.15

Requests additional attributes for the given feature or FeatureSet. In some profiles, such as Visualization and Labeling, apps only request the data attributes required for rendering each feature or label. Some expressions dynamically reference field names with variables rather than string literals. This makes it hard for rendering and labeling engines to detect fields required for rendering. This function allows you to explicitly indicate required fields as a list. You can also request all or a subset of fields using a wildcard. Because expressions execute on a per feature basis, the wildcard should be used with caution, especially in layers containing many features. Requesting too much data can result in very poor app performance.

Name Type Description
feature Feature | FeatureSet The feature to which the requested fields will be attached. In profiles that support accessing data, this can be a FeatureSet.
...field1, field2 Text An ongoing list of field names to request for the given feature or FeatureSet. List only fields required for use in the expression. If necessary, you can request all fields using the wildcard * character. However, this should be avoided to prevent loading an unnecessary amount of data that can negatively impact app performance.

Returns: Null

Example

Requests fields not easily detected by the renderer

// Request multiple years of population data if the
// fields cannot be easily detected by the renderer or labels
Expects($feature, 'POP_2020', 'POP_2010')
var thisYear = 2020;
var lastDecade = thisYear - 10;
return $feature['POP_'+thisYear] - $feature['POP_'+lastDecade]

Requests the POPULATION field for the features in the cluster

// If the layer is clustered based on count,
// only the OBJECTID field is requested by default.
// To display the sum of the POPULATION field
// for all features in the cluster, we must
// explicitly request the POPULATION data. 
Expects($aggregatedFeatures, 'POPULATION')
Text(Sum($aggregatedFeatures, 'POPULATION'), '#,###')

Requests all data matching a pattern in the field name

// Request all the data beginning with 'POP'. This is
// necessary because the renderer can't easily detect
// the required fields based on this expression
Expects($feature, 'POP*')

var startYear = 1880;
var endYear = 2020;
var changes = [];

for(var y=startYear; y<endYear; y+=10){
  var startPop = $feature['POP_' + y];
  var endPop = $feature['POP_' + (y+10)];
  var change = endPop - startPop;
  Push(changes, change);
}
Max(changes);

Requests all data for the feature

// Request all fields because the required fields may
// be based on unknown information like a relative date
Expects($feature, '*')

var casesToday = $feature[ 'CASES_' + Text(d, 'MM_DD_Y') ];
var casesYesterday = $feature[ 'CASES_' + Text(DateAdd( Today(), -1, 'days', 'MM_DD_Y') ];
// Change in cases from yesterday
return casesToday - casesYesterday;

Feature

Feature( geometry, name1, value1, [... nameN, valueN]? ) -> Feature

Creates a new feature. Alternatively, it can be called with object notation: Feature({geometry: {}, attributes: {...}}) or with two parameters: Feature(geometry, attributes);.

Name Type Description
geometry Geometry The geometry of the feature.
name1 Text The first attribute's name.
value1 Text | Date | Number | Boolean The first attribute's value.
[... nameN, valueN] * optional Ongoing name/value pairs for each attribute in the feature.

Returns: Feature

Example

Feature(pointGeometry, 'city_name', 'Spokane', 'population', 210721)
Create a feature from another feature.
var dict = { hello:10 }
var p = point({x:10, y:20, spatialReference:{wkid:102100}})
var ftr1 = Feature(p,dict)
var ftr2 = Feature(ftr1)
Create a feature from a JSON string.
var JSONString = "{'geometry':{'x':10,'y':20,'spatialReference':{'wkid':102100}},'attributes':{'hello':10}}"
Feature(JSONString)

FeatureSet

FeatureSet( definition ) -> FeatureSet

Since version 1.5

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Creates a new FeatureSet from JSON according to the ArcGIS REST spec. See the snippet below for an example of this.

Name Type Description
definition Text The JSON describing a set of features. The JSON must be contained in a text value.

Returns: FeatureSet

Example

Create a FeatureSet from JSON.
// JSON representation of the feature used in the snippet below
// {
//   'fields': [{
//     'alias': 'RANK',
//     'name': 'RANK',
//     'type': 'esriFieldTypeInteger'
//   }, {
//     'alias': 'ELEV_m',
//     'name': 'ELEV_m',
//     'type': 'esriFieldTypeInteger'
//   }],
//   'spatialReference': { 'wkid': 4326 },
//   'geometryType': 'esriGeometryPoint',
//   'features': [{
//     'geometry': {
//       'spatialReference': { 'wkid': 4326 },
//       'x': -151.0063,
//       'y': 63.069
//     },
//     'attributes': {
//       'RANK': 1,
//       'ELEV_m': 6168
//     }
//   }]
// };
// The Dictionary representation of the FeatureSet must be a stringified object
var features = FeatureSet('{"fields":[{"alias":"RANK","name":"RANK","type":"esriFieldTypeInteger"},{"alias":"ELEV_m","name":"ELEV_m","type":"esriFieldTypeInteger"}],"spatialReference":{"wkid":4326},"geometryType":"esriGeometryPoint","features":[{"geometry":{"spatialReference":{"wkid":4326},"x":-151.0063,"y":63.069},"attributes":{"RANK":1,"ELEV_m":6168}}]}')

FeatureSetByAssociation

FeatureSetByAssociation( feature, associationType, terminalName? ) -> FeatureSet

Since version 1.9

Profiles: Attribute Rules | Dashboard Data | Popup | Feature Reduction Popup | Tasks

Returns all the features associated with the input feature as a FeatureSet. This is specific to Utility Network workflows.

Name Type Description
feature Feature The feature from which to query for all associated features. This feature must be coming from a feature service; feature collections are not supported.
associationType Text The type of association with the feature to be returned.

Possible Values: connected | container | content | structure | attached
Added at 1.10: junctionEdge | midspan
terminalName Text optional Only applicable to connected association types.

Returns:

Type Description
FeatureSet Returns a FeatureSet containing features with the field specification described in the table below.
Return Object Specification Table
Name Type Description
className Text The class name based on the value of TONETWORKSOURCEID or FROMNETWORKSOURCEID.
globalId Text The Global ID of the feature in the other table (i.e. either the value of TOGLOBALID or FROMGLOBALID).
isContentVisible Number Can either be a value of 1 (visible) or 0 (not visible). This value represents the visibility of the associated content and is only applicable for containment associations.
objectId Text The ObjectID of the row in the association table.
percentAlong Number Applies to midspan association types. Returns a floating point number from 0-1 indicating the location (as a ratio) of the junction along the edge.
side Text Applies to junctionEdge association types. Indicates which side the junction is on.

Possible values: from | to

Example

Returns all assets that have connectivity associations with the low side terminal of the transformer.
FeatureSetByAssociation($feature, 'connected', 'Low');
Returns the number of electric devices associated with the feature
var allContent = FeatureSetByAssociation ($feature, "content");
var devicesRows = Filter(allContent, "className = 'Electric Device'");
var devicesCount = Count(devicesRows);
return devicesCount;

FeatureSetById

FeatureSetById( map, id, fieldList?, includeGeometry? ) -> FeatureSet

Since version 1.5

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Creates a FeatureSet from a Feature Layer based on its layer ID within a map or feature service. Limiting the number of fields in the request and excluding the geometry can improve the performance of the script.

Name Type Description
map FeatureSetCollection The map or feature service containing one or more layers from which to create a FeatureSet. Typically, this value is the $map or $datastore global.
id Text The ID of the layer within the given map. This layer must be created from a feature service; feature collections are not supported. *Please note that this must be a string literal.
fieldList Text[] optional The fields to include in the FeatureSet. By default, all fields are included. To request all fields in the layer, set this value to ['*']. Limiting the number of fields improves the performance of the script.
includeGeometry Boolean optional Indicates whether to include the geometry in the features. By default, this is true. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.

Returns: FeatureSet

Example

Returns the number of features in the layer with the id DemoLayerWM_1117 in the given map.
var features = FeatureSetById($map,'DemoLayerWM_1117', ['*'], true);
Count( features );

FeatureSetByName

FeatureSetByName( map, title, fieldList?, includeGeometry? ) -> FeatureSet

Since version 1.5

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Creates a FeatureSet from a Feature Layer based on its name within a map or feature service. Keep in mind this name is not necessarily unique. It is therefore more appropriate to create a FeatureSet using FeatureSetById(). Limiting the number of fields in the FeatureSet and excluding the geometry can improve the performance of the script.

Name Type Description
map FeatureSetCollection The map or feature service containing one or more layers from which to create a FeatureSet. Typically, this value is the $map or $datastore global.
title Text The title of the layer within the given map. This layer must be created from a feature service; feature collections are not supported. *Please note that this must be a string literal.
fieldList Text[] optional The fields to include in the FeatureSet. By default, all fields are included. To request all fields in the layer, set this value to ['*']. Limiting the number of fields improves the performance of the script.
includeGeometry Boolean optional Indicates whether to include the geometry in the features. By default, this is true. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.

Returns: FeatureSet

Example

Returns the number of features in the layer with the title 'Bike routes' in the given map.
var features = FeatureSetByName($map,'Bike routes', ['*'], true);
Count( features );

FeatureSetByPortalItem

FeatureSetByPortalItem( portal, itemId, layerId, fieldList?, includeGeometry? ) -> FeatureSet

Since version 1.8

Profiles: Dashboard Data | Field Calculate | Popup | Feature Reduction Popup | Tasks

Creates a FeatureSet from a Feature Layer in a portal item from a given Portal. Limiting the number of fields in the FeatureSet and excluding the geometry can improve the performance of the script.

Name Type Description
portal Portal The Portal from which to query features from a given portal item ID.
itemId Text The GUID of the portal item referencing a feature layer or feature service. *Please note that this must be a string literal.
layerId Number The ID of the layer in the feature service. This layer must be created from a feature service; feature collections are not supported.
fieldList Text[] optional The fields to include in the FeatureSet. By default, all fields are included. To request all fields in the layer, set this value to ['*']. Limiting the number of fields improves the performance of the script.
includeGeometry Boolean optional Indicates whether to include the geometry in the features. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.

Returns: FeatureSet

Example

Returns the number of features in the layer from a different portal than the feature in the map
var features = FeatureSetByPortalItem( Portal('https://www.arcgis.com'), '7b1fb95ab77f40bf8aa09c8b59045449', 0, ['Name', 'Count'], false );
Count( features );

FeatureSetByRelationshipName

FeatureSetByRelationshipName( feature, relationshipName, fields?, includeGeometry? ) -> FeatureSet

Since version 1.8

Profiles: Attribute Rules | Dashboard Data | Field Calculate | Popup | Feature Reduction Popup | Tasks

Returns the related records for a given feature as a FeatureSet.

Name Type Description
feature Feature The feature from which to fetch related records. This feature must be coming from a feature service; feature collections are not supported.
relationshipName Text The name of the relationship according to the feature service associated with the given feature.
fields Text[] optional The fields to return in the FeatureSet. This list includes fields from both the relationship table and the input Feature.
includeGeometry Boolean optional Indicates whether to return the geometry for the resulting features.

Returns: FeatureSet

Example

var results = FeatureSetByRelationshipName($feature, 'Election_Results', ['*'], false)
Sum(results, 'democrat + republican + other')

Filter

Filter( featureSet, filter ) -> FeatureSet

Since version 1.5

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Filters a FeatureSet based on a SQL92 expression.

Name Type Description
featureSet FeatureSet The FeatureSet, or layer, to filter.
filter Text The SQL92 expression used to filter features in the layer. This expression can substitute an Arcade variable using the @ character. See the snippet below for an example.

Returns: FeatureSet

Example

Filter features using a SQL92 expression
// Returns all features with a Population greater than 10,000
var result = Filter($layer, 'POPULATION > 10000');
Filter features using a SQL92 expression with a variable substitute
// Returns all features with a Population greater than the dataset average
var averageValue = Average($layer, 'POPULATION')
var result = Filter($layer, 'POPULATION > @averageValue');

First

First( items ) -> *

Returns the first element in an array or FeatureSet. Returns null if the array or FeatureSet is empty.

Name Type Description
items Array | FeatureSet The array from which to return the first feature. In profiles that support accessing data, this can be a FeatureSet.

Returns: *

Example

prints 'orange'

First(['orange', 'purple', 'gray'])

returns the area of the first feature in the layer.

Area( First($layer) )

FromJSON

FromJSON( jsonText ) -> Dictionary / Array / String / Boolean / Number

Since version 1.14

Converts stringified (serialized) JSON objects into their equivalent Arcade data types.

Name Type Description
jsonText Text The stringified JSON to deserialize to an Arcade data type.

Returns: Dictionary | Array | String | Boolean | Number

Example

Converts text to a boolean

FromJSON("true")
// Returns true

Converts text to a number

fromJSON("731.1")
// returns 731.1

Converts text to a dictionary

var d = fromJSON('{"kids": 3, "adults": 4 }')
d.kids + d.adults
// returns 7

Converts text to an array

fromJSON('["one", 2, "three", false]')
// returns [ "one", 2, "three", false ]

Converts text to null

fromJSON("null")
// returns null

GdbVersion

GdbVersion( feature ) -> Text

Since version 1.12

Returns the name of the current geodatabase version for branch or versioned data. When the data is not in a multi-user geodatabase, an empty string will be returned. See Overview of Versioning for more information.

Name Type Description
feature Feature | FeatureSet A Feature or FeatureSet from which to return the current geodatabase version of the associated layer.

Returns: Text

Example

Returns the geodatabase version of the given feature

GdbVersion($feature)

GetFeatureSet

GetFeatureSet( feature, source? ) -> FeatureSet

Since version 1.14

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Gets the FeatureSet in which the input feature belongs. The returned FeatureSet represents all features from the input feature's parent/root layer or table.

Name Type Description
feature Feature The feature belonging to a parent or root FeatureSet.
source Text optional Indicates the source FeatureSet to return.

Possible Values:
  • datasource - (default) Returns all the features from the input feature's data source without any filters or definition expressions as a FeatureSet.
  • root - Returns the initial FeatureSet to which the input feature belongs. This may be a filtered subset of all the features in the data source.
  • parent - Returns the parent FeatureSet of the input feature. This can be a smaller set of features than the original data source or root FeatureSet.

Returns: FeatureSet

Example

Returns a FeatureSet representing all the features in the data source.
// The data source for the 'Bike routes' layer has 2,000 features. 
// The map sets a definition expression on the 'Bike routes' layer and filters it to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10) 
var f = First(fs2)
GetFeatureSet(f)
// returns a FeatureSet representing the data source with 2,000 features
Returns the root FeatureSet of the feature.
// The data source for the 'Bike routes' layer has 2,000 features. 
// The map sets a definition expression on the 'Bike routes' layer and filters it to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10) 
var f = First(fs2)
GetFeatureSet(f, 'root')
// returns the root FeatureSet representing 100 features
Returns the parent FeatureSet of the feature.
// The data source for the 'Bike routes' layer has 2,000 features. 
// The map sets a definition expression on the 'Bike routes' layer and filters it to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10) 
var f = First(fs2)
GetFeatureSet(f, 'parent')
// returns the parent FeatureSet representing 10 features
Returns the number of features in the data source table within 1 mile of the feature.
var fullFeatureSet = GetFeatureSet($feature);
var featuresOneMile = Intersects(fullFeatureSet, BufferGeodetic($feature, 1, 'miles'))
Count(featuresOneMile)

GetUser

This function has 2 signatures:

GetUser( portal, username? ) -> Dictionary

Since version 1.12

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, an empty string will be returned.

Name Type Description
portal FeatureSet | Portal A FeatureSet or Portal from which to return the current user.
username Text optional The username of the user you want to return. Only limited information will be returned based on your permissions when making the request.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
id Text The user id of the returned user.
username Text The username of the returned user.
fullName Text The user's first and last name.
email Text The email address associated with the user's account.
groups Text[] An array of groups that the user belongs to.
role Text The role that the user plays within their organization (e.g. Administrator, Publisher, User, Viewer, or Custom).
privileges Text[] An array of privileges that the user has within their organization (e.g. edit, view, etc).

Example

Returns the dictionary for the user currently logged in based on the workspace connection from the given portal.

GetUser(Portal('https://www.arcgis.com'))

Returns information about the user "tester".

GetUser($layer, "tester")
// returns {"id": "12", "username": "tester", "name":"Testy Tester", "email": "tester@example.com", ...}

GetUser( portal, extensions? ) -> Dictionary

Since version 1.12

Profiles: Attribute Rules | Popup | Field Calculate | Feature Reduction Popup | Tasks

Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, an empty string will be returned.

Name Type Description
portal FeatureSet | Portal A FeatureSet or Portal from which to return the current user.
extensions Boolean optional Determines if the userLicenseTypeExtensions will be returned in the dictionary.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
id Text The user id of the returned user.
username Text The username of the returned user.
fullName Text The user's first and last name.
email Text The email address associated with the user's account.
groups Text[] An array of groups that the user belongs to.
role Text The role that the user plays within their organization (e.g. Administrator, Publisher, User, Viewer, or Custom).
privileges Text[] An array of privileges that the user has within their organization (e.g. edit, view, etc).
userLicenseTypeExtensions Text[] An array of the license type extensions associated with the user's account (e.g. "Utility Network", "Parcel Fabric", etc). The extensions parameter must be set to true in order for this to be returned.

Example

Returns information about the user currently logged in based on the workspace connection from a layer with user extensions.

GetUser($layer, true)

GroupBy

GroupBy( featureset, groupByFields, statistics ) -> FeatureSet

Since version 1.8

Profiles: Attribute Rules | Dashboard Data | Field Calculate | Popup | Feature Reduction Popup | Tasks

Returns statistics as a FeatureSet for a set of grouped or distinct values.

Name Type Description
featureset FeatureSet A FeatureSet from which to return statistics for unique values returned from a given set of fields and/or expressions.
groupByFields Text | Text[] | Object[] The field(s) and/or expression(s) from which to group statistics by unique values. This parameter can be a single field name, an array of field names, or an array of objects that specify column names paired with an expression (typically the field name) for the output FeatureSet. If an array of objects is specified, the following specification must be followed for each object.

PropertyDescription
nameThe name of the column to store the result of the given expression.
expressionA SQL-92 expression from which to group statistics. This is typically a field name.
statistics Object | Object[] The summary statistics to calculate for each group. This parameter can be an object or array of objects that specify output statistics to return for each group. The specification in the following table must be used.

PropertyDescription
nameThe name of the column to store the result of the given statistical query in the output FeatureSet.
expressionA SQL-92 expression or field name from which to query statistics.
statisticThe statistic type to query for the given field or expression.

Possible Values: SUM | COUNT | MIN | MAX | AVG | STDEV | VAR

Returns: FeatureSet

Example

Returns the count of each tree type

var treeStats = GroupBy($layer, 'TreeType', { name: 'NumTrees', expression: '1', statistic: 'COUNT' });
// treeStats contains features with columns TreeType and NumTrees
// Each unique tree type will have a count

Returns the count and the average height of each tree type

var treeStats = GroupBy($layer,
  [  // fields/expressions to group statistics by
    { name: 'Type', expression: 'TreeType'},
    { name: 'Status', expression: 'TreeStatus'}
  ], 
  [  // statistics to return for each unique category
    { name: 'Total', expression: '1', statistic: 'COUNT' }, 
    { name: 'AvgHeight', expression: 'Height', statistic: 'AVG' }, 
    { name: 'MaxPercentCoverage', expression: 'CoverageRatio * 100', statistic: 'MAX' }
  ]
);
// treeStats contains features with columns Type, Status, Total, AvgHeight, MaxPercentCoverage
// Each unique tree type (combination of type and status) will have a count, average height, and maximum value of percent coverage

Guid

Guid( format? ) -> Text

Since version 1.3

Returns a random GUID as a string.

Name Type Description
format Text optional An named format for the GUID. The default value is digits-hyphen-braces.

Possible Values: digits / digits-hyphen / digits-hyphen-braces / digits-hyphen-parentheses

Returns: Text

Example

Returns a value similar to {db894515-ed21-4df1-af67-36232256f59a}

Guid()

Returns a value similar to d00cf4dffb184caeb8ed105b2228c247

Guid('digits')

Hash

Hash( variable ) -> Number

Since version 1.12

Generates a hash code value for the given variable.

Name Type Description
variable Text | Number | Boolean | Date | Array | Dictionary | Geometry The variable to be hashed.

Returns: Number

Example

Returns 1649420691.

Hash('text value')

HasKey

HasKey( feature, key ) -> Boolean

Indicates whether a dictionary or feature has the input key.

Name Type Description
feature Dictionary | Feature The dictionary or feature to check for a key or field name.
key Text The key or field name to check.

Returns: Boolean

Example

prints true

var d = Dictionary('Port Hope', 16214,  'Grafton', '<1000', 'Cobourg', 18519);
HasKey(d, 'Cobourg');

Includes

Includes( inputArray, value ) -> Boolean

Since version 1.12

Determines whether an array contains a given value. Returns true if the value is found within the array.

Name Type Description
inputArray Array The input array.
value * The value to look for in the given array.

Returns: Boolean

Example

Returns true.

Includes(['orange', 'purple', 'gray'], 'purple')

Returns false.

Includes(['orange', 'purple', 'gray'], 'red')

IndexOf

IndexOf( inputArray, item ) -> Number

Returns the zero-based index location of the input item in an array. If item does not exist, then -1 is returned.

Name Type Description
inputArray Array The array to search.
item * The item to locate in the array.

Returns: Number

Example

prints 2

var num = [1,2,3,4];
return indexof(num, 3);

Insert

Insert( inputArray, index, value )

Since version 1.12

Inserts a new value into an array at a given index. Existing elements positioned at or above the given index will shift up one index value. The array increases in size by one.

Name Type Description
inputArray Array The array to insert the new value into.
index Number The index of the array where the new value should be inserted. An index of 0 will insert the value at the beginning of the array. An index that equals the size of the array will insert the value at the end of the array. An index greater than the size of the array will cause an error. If a negative index is provided, it will be used as an offset from the end of the array.
value * The value to insert into the array.

Example

var colors = ['orange', 'purple', 'gray']
Insert(colors, 1, 'yellow')
// colors = ['orange','yellow','purple','gray']
var colors = ['orange', 'purple', 'gray']
Insert(colors, -1, 'yellow')
// colors = ['orange','purple','yellow','gray']

IsNan

IsNan( value ) -> Boolean

Since version 1.5

Indicates whether the input value is not a number (NaN). A number is considered NaN in one of the following scenarios:

  • 0/0
  • Infinity / Infinity
  • Infinity * 0
  • Any operation in which NaN is an operand
  • Casting a non-numeric string or undefined to a number

Name Type Description
value * The value to check if it is NaN.

Returns: Boolean

Example

// Returns true
IsNan(Infinity / Infinity)
// Returns false
IsNan('4')

NextSequenceValue

NextSequenceValue( inputSequenceName ) -> Number

Since version 1.4

Profiles: Attribute Rule Calculation

Returns the next sequence value from the database sequence specified. If inputSequenceName does not exist, the expression will error.

Name Type Description
inputSequenceName Text The name of the sequence. This must already be configured in the database.

Returns: Number

Example

Returns a number with the next sequence value

NextSequenceValue('PipeIDSeq')

Number

Number( value, pattern? ) -> Number

Parses the input value to a number.

Name Type Description
value * The value to convert to a number.
pattern Text optional The format pattern string used to parse numbers formatted in a localized context from a string value to a number. The table below describes the characters that may be used in the pattern.

ValueDescription
0Mandatory digits
#Optional digits
%Divide by 100

Returns: Number

Example

Parses a number using a grouping separator appropriate for the local in which the expression is executed

returns 1365

Number('1,365', ',###')
Remove strings from number.

prints 10

Number('abc10def', 'abc##def')
Specify minimum digits past 0 as two and maximum digits past 0 as 4.

prints 10.456

Number('10.456','00.00##')
Specify minimum digits past 0 as two and maximum digits past 0 as 4. The left and right side of the function must match or NaN is returned.

prints NaN

Number('10.4','00.00##')
Indicate the size of the repeated group and the final group size of the input value.

prints 1212456

Number('12,12,456', ',##,###')
If there is a negative subpattern, it serves only to specify the negative prefix and suffix.

prints -1223345

Number('-12,23,345', ',##,###;-,##,###')
Divide by 100. Maximum of three decimal places can be input.

prints 0.9999

Number('99.99%', '#.##%')

OrderBy

OrderBy( featureSet, expression ) -> FeatureSet

Since version 1.5

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Feature Reduction Popup | Tasks

Orders a FeatureSet by using a SQL92 OrderBy clause.

Name Type Description
featureSet FeatureSet The FeatureSet, or layer, to order.
expression Text The SQL92 expression used to order features in the layer.

Returns: FeatureSet

Example

Order features by population where features with the highest population are listed first
OrderBy($layer, 'POPULATION DESC')
Order features by rank in ascending order
OrderBy($layer, 'Rank ASC')

Pop

Pop( inputArray ) -> *

Since version 1.12

Removes and returns the element at the end of the array. If the array is empty, then an error is thrown.

Name Type Description
inputArray Array The input array from which the last element will be removed and returned.

Returns: *

Example

Returns 'gray'. The input array will now equal ['orange', 'purple'].

Pop(['orange', 'purple', 'gray'])

Portal

Portal( url ) -> Portal

Since version 1.8

Profiles: Field Calculate | Popup | Feature Reduction Popup | Tasks

Creates a reference to an ArcGIS Portal.

Name Type Description
url Text The url of the portal.

Returns: Portal

Example

Query features from a portal item in ArcGIS Online

var arcgisPortal = Portal('https://www.arcgis.com');
var features = FeatureSetByPortalItem(arcgisPortal, '7b1fb95ab77f40bf8aa09c8b59045449', 0, ['Name', 'Count'], false);

Enterprise Portal

Portal('https://www.example.com/arcgis')

Push

Push( inputArray, value ) -> Number

Since version 1.12

Adds an element to the end of an array and returns the new length of the array.

Name Type Description
inputArray Array The array to have elements pushed to.
value * The value to add as the last element of the input array.

Returns: Number

Example

Returns 4. The input array will now equal ['orange', 'purple', 'gray', 'red'].

Push(['orange', 'purple', 'gray'], 'red').

Resize

Resize( inputArray, newSize, value? )

Since version 1.12

Changes the number of elements in an array to the specified size. It can be used to expand the array or truncate it early. After resizing, attempting to index beyond the new last element will result in an error, except for the case of indexing the next element, which will continue to expand the array by one element.

Name Type Description
inputArray Array The array to be resized.
newSize Number The number of elements desired in the resized array.
value * optional The optional value that will be used for any new elements added to the array. If no value is specified, the newly added elements will have a null value.

Example

Returns ['orange', 'purple', 'gray', null, null]

var colors = ['orange', 'purple', 'gray']
Resize(colors, 5)
return colors;

Returns ['orange', 'purple', 'gray', 'red', 'red']

var colors = ['orange', 'purple', 'gray']
Resize(colors, 5, 'red')
return colors;

Returns ['orange']

var colors = ['orange', 'purple', 'gray']
Resize(colors, 1)
return colors

Reverse

Reverse( inputArray ) -> Array

Reverses the contents of the array in place.

Name Type Description
inputArray Array The array to be reversed.

Returns: Array

Example

returns ['gray', 'purple', 'orange']

Reverse(['orange', 'purple', 'gray'])

Schema

Schema( feature ) -> Dictionary

Since version 1.11

Profiles: Attribute Rules | Dashboard Data | Popup | Field Calculate | Velocity | Feature Reduction Popup | Tasks

Returns the schema description of the provided Feature or FeatureSet.

Name Type Description
feature Feature | FeatureSet The feature whose schema to return. In profiles that support accessing data, this can be a FeatureSet.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
objectIdField Text The objectId field of the Feature or FeatureSet.
globalIdField Text The global ID field of the Feature or FeatureSet. Returns "" if not globalId-enabled.
geometryType Text The geometry type of features in the Feature or FeatureSet. Returns esriGeometryNull for tables with no geometry.

Possible values: esriGeometryPoint, esriGeometryLine, esriGeometryPolygon, esriGeometryNull
fields Dictionary[] Returns an array of dictionaries describing the fields in the Feature or FeatureSet. Each dictionary describes the field name, alias, type, subtype, domain, length, and whether it is editable and nullable.

Slice

Slice( inputArray, startIndex?, endIndex? ) -> Array

Since version 1.12

Returns a copy of the contents of a portion of an array between two indexes as a new array.

Name Type Description
inputArray Array The array to be sliced.
startIndex Number optional The index from which to start the slice. Defaults to 0. If a negative index is provided, it will be used as an offset from the end of the array.
endIndex Number optional The index where the slice will end. The value at this index will not be included in the returned array. Defaults to the array size.

Returns: Array

Example

Returns ['purple', 'gray']

Slice(['orange', 'purple', 'gray', 'red', 'blue'], 1, 3)

Returns ['red', 'blue']

Slice(['orange', 'purple', 'gray', 'red', 'blue'], 3)

Returns ['orange', 'purple', 'gray', 'red', 'blue']

Slice(['orange', 'purple', 'gray', 'red', 'blue'])

Returns ['blue']

Slice(['orange', 'purple', 'gray', 'red', 'blue'], -1)

Sort

Sort( inputArray, comparator? ) -> Array

Sorts an array by ASCII value. If all the items in the array are the same type, an appropriate sort function will be used. If they are different types, the items will be converted to strings. If the array contains objects, and no user defined function is provided, no sort will happen.

Name Type Description
inputArray Array The array to sort.
comparator Text optional The name of a user defined function to be used for the sort.

Returns: Array

Example

returns ['$', 1, 'A', 'a']

Sort([1, 'a', '$', 'A'])
Sort using a user defined function

returns '[{ 'AGE': 24, 'NAME': 'Emma' }, { 'AGE': 25, 'NAME': 'Sam' }, { 'AGE': 27, 'NAME': 'Bob' } ]'

var peopleArray = [{ 'NAME': 'Sam', 'AGE': 25 }, {'NAME': 'Bob', 'AGE': 27 },{ 'NAME': 'Emma', 'AGE': 24 }];
function compareAge(a,b){
  if (a['AGE']<b['AGE'])
    return -1;
  if (a['AGE']>b['AGE'])
    return 1;
  return 0;
}
return Sort(peopleArray, compareAge);

Splice

Splice( value1, [...valueN]? ) -> Array

Since version 1.12

Concatenates all parameters together into a new array.

Name Type Description
value1 * A value to be spliced into a new array.
[...valueN] * optional Ongoing values to be spliced into a new array.

Returns: Array

Example

Returns ['orange', 'purple', 1, 2, 'red']

Splice(['orange', 'purple'], 1, 2, 'red')

Returns [1, 2, 3, 4]

Splice([1,2], [3,4])

SubtypeCode

SubtypeCode( feature ) -> Number / Text / Date

Since version 1.11

Returns the subtype code for a given feature.

Name Type Description
feature Feature The Feature from which to get the subtype code.

Returns: Number | Text | Date

Example

Returns the code of the subtype

// feature has a field named `assetGroup`
// with the subtype described in the Subtypes function example
SubtypeCode($feature)  // returns 1

SubtypeName

SubtypeName( feature ) -> Text

Since version 1.11

Returns the subtype name for a given feature.

Name Type Description
feature Feature The Feature from which to get the subtype name.

Returns: Text

Example

Returns the name of the subtype

// feature has a field named `assetGroup`
// with the subtype described in the Subtypes function example
SubtypeName($feature) // returns "Single Phase"

Subtypes

Subtypes( feature ) -> Dictionary

Since version 1.11

Returns the subtype coded value Dictionary. Returns null when subtypes are not enabled on the layer.

Name Type Description
feature Feature | FeatureSet The Feature from which to get subtypes. In profiles that support accessing data, this can be a FeatureSet.

Returns:

Type Description
Dictionary Returns a dictionary described by the properties below.
Return Object Specification Table
Name Type Description
subtypeField Text The field containing a subtype in the FeatureSet.
subtypes Dictionary[] An array of dictionaries describing the subtypes. Each dictionary has a code property, which contains the actual field value, and a name property containing a user-friendly description of the value (e.g. { code: 1, name: "pavement" })

Example

Returns subtypes with coded values from a feature

Subtypes($feature)
// returns the following dictionary
// {
//   subtypeField: 'assetGroup',
//   subtypes: [
//     { name: "Unknown", code: 0 },
//     { name: "Single Phase", code: 1 },
//     { name: "Two Phase", code: 2 }
//   ]
// }

Returns subtypes with coded values from a FeatureSet

var fsTransformer = FeatureSetByName($datastore, "Transformer")
Subtypes(fsTransformer)
// returns the following dictionary
// {
//   subtypeField: 'assetGroup',
//   subtypes: [
//     { name: "Unknown", code: 0 },
//     { name: "Single Phase", code: 1 },
//     { name: "Two Phase", code: 2 }
//   ]
// }

Text

Text( value, format? ) -> Text

Converts its argument into a string and optionally formats it. Returns null if it fails.

Name Type Description
value * A value to be converted to a string (e.g. date, number or other type). When a date is provided, this function assumes the date/time object is in UTC and automatically converts the value to the local time of the client executing the expression. If the date/time value returned from the database already represents local time, then you should use the toUTC function to avoid applying an extra offset.
format Text optional Formatting string for dates or numbers. See the list of possible values below.

ValueDescription
0Digit
#Digit, omitting leading/trailing zeros
DDay of the month, not padded (1 - 31).
DDDay of the month, padded (01 - 31).
DDDOrdinal day of the year (1 - 365).
dDay of the week (1 - 7)
dddAbbreviated day of the week (e.g. Mon)
ddddFull day of the week (e.g. Monday).
MMonth number (1 - 12)
MMMonth number, padded (01 - 12).
MMMAbbreviated month name (e.g. Jan).
MMMMFull month name (e.g. January)
mMinutes, not padded (0 - 59).
mmMinutes, padded (00 - 59).
YFull year
YYTwo-digit year
hCivilian hours, not padded (0 - 12)
hhCivilian hours, padded (00 - 12)
HMilitary hours, not padded (0 - 24)
HHMilitary hours, padded (00 - 24)
sSeconds, not padded (0 - 59)
ssSeconds, padded (00 - 59)

Returns: Text

Example

Pad the number to the left of the decimal

prints '0123'

Text(123, '0000')
Restrict the number to the left of the decimal

prints '23'

Text(123, '00')
Group the number by thousands

prints '1,234'

Text(1234, '#,###')
Round the number to two decimal places

prints '12,345,678.12'

Text(12345678.123, '#,###.00')
Format number as currency

prints '$1,234.55'

Text(1234.55, '$#,###.00')
Round the number to two decimal places

prints '1.24'

Text(1.236, '#.00')
Maintain significant digits and group by thousands

prints '1,234.568'

Text(1234.5678, '#,##0.00#')
Format the number and format positive/negative - if there is a negative subpattern, it serves only to specify the negative prefix and suffix

prints 'Basement 2'

Text(-2, 'Floor #;Basement #')

prints 'Floor 2'

Text(2, 'Floor #;Basement #')
Multiply by 100 and format as percentage

prints '30%'

Text(0.3, '#%')
Format date and time

prints the date at the moment. eg 'Tuesday, October 25, 2016 @ 08:43:11'

Text(Now(), 'dddd, MMMM D, Y @ h:m:s')
Date stored in the datetime field already represents local time, but Arcade assumes it is UTC

Offsets the local time to UTC to avoid applying the timezone offset twice.

Text(ToUTC($feature.datetime), 'dddd, MMMM D, Y @ h:m:s')

ToHex

ToHex( value ) -> Text

Since version 1.12

Converts an integer to a hexidecimal representation.

Name Type Description
value Number The value to be converted to a hexidecimal value.

Returns: Text

Example

Returns "64".
ToHex(100)
Returns the hexidecimal representation for the color royal blue, "#4169E1", from its RGB values
var r = ToHex(65); // returns "41"
var g = ToHex(105); // returns "69"
var b = ToHex(225); // returns "E1"
Concatenate("#",r,g,b)
// Returns "#4169E1"

Top

Top( items, numElements ) -> Array / FeatureSet

Since version 1.3

Truncates the input array or FeatureSet and returns the first given number of elements.

Name Type Description
items Array | FeatureSet The array to truncate. In profiles that support accessing data, this can be a FeatureSet.
numElements Number The number of elements to return from the beginning of the array or FeatureSet.

Returns: Array | FeatureSet

Example

returns [ 43,32,19 ]
Top([ 43,32,19,0,3,55 ], 3)
Returns the top 5 features with the highest population
Top( OrderBy($layer, 'POPULATION DESC'), 5 )

TypeOf

TypeOf( value ) -> Text

Returns the type of the input value. Will return one of the following types: Array, Date, Text, Boolean, Number, Dictionary, Feature, Point, Polygon, Polyline, Multipoint, Extent, Function, Unrecognized Type.

Name Type Description
value * The input value, variable, or feature attribute.

Returns: Text

Example

prints 'Boolean'

TypeOf(true)

prints 'Date'

TypeOf(Now())

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.