Debugging functions

Functions for debugging expressions.


Console

Console([value1, ..., valueN]?) -> Null

Since version 1.0

Function bundle: Core

Logs a message to a console for debugging purposes. This function can be especially useful for debugging expressions. Unlike most functions, Console() does not return a value; rather, it logs messages in a separate window for data inspection purposes only. The successful use of this function has no computational impact on the evaluation of the expression. The location of the console depends on the profile or context where the expression is authored. If authoring an expression in ArcGIS Online, logged messages are accessed in the "Console" tab of the results window in the Arcade Editor. Expressions executed in web clients will log console messages to the browser console.

Parameter

  • [value1, ..., valueN] (Optional): Any - A list of variables, text, number, or dictionary to output in the messages window.

Return value: Null

Example

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

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// The console 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 maxValue = -Infinity;
  for (var i in yourArray) {
    maxValue = IIf(yourArray[i] > maxValue, yourArray[i], maxValue);
    Console('current item is: ' + i + ', but maxValue = ' + maxValue);
  }
  return maxValue;
}
var myArray = [ 10, 0, 84, 30 ];
findMax(myArray);

GetEnvironment

GetEnvironment() -> Dictionary

Since version 1.23

Function bundle: Core

Provides information about the context and environment where the Arcade expression is executed.

Return value: Dictionary
Returns a dictionary containing the properties below. The properties returned may vary based on where you are running the Arcade expression, so it is recommended to use the HasValue function to ensure the desired environment property exists.

  • version: Text - The Arcade version. See the Arcade version matrix for more information about versioning.

  • engine: Text - The engine executing the Arcade expression. Possible values: web, native, jvm

  • engineVersion: Text - The version of the engine executing the Arcade expression. See the Arcade version matrix for more information about versioning.

  • application: Text - The application in which the Arcade expression is run. It is up to application developers to set this value. Therefore, this property may be empty depending on the app in which the expression executes.

  • locale: Text - The locale of the client or system.

  • spatialReference: Dictionary - The spatial reference of the Arcade context.

    • wkid: Number - The well-known ID of the spatial reference.
  • timeZone: Text - Since 1.24 The default time zone of the expression's execution context. This is used when constructing and displaying Date values if a time zone is not otherwise specified.

Additional resources

Example

Gets the environment of the client or system

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
var env = GetEnvironment()
// equals the following when executed in a JavaScript Maps SDK application
// {
//  "version":"1.23",
//  "engine":"web",
//  "engineVersion":"4.27",
//  "application":"",
//  "locale":"en-US",
//  "spatialReference": { "wkid": 102100 }
// }
var locale = IIF(HasValue(env, "locale"), env.locale, "");
// returns the locale if it exists, otherwise returns an empty text value
return locale;

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