Skip to content

Experience Builder Widget Formatting

Since version: 1.32

The Experience Builder Widget Formatting profile is used for widgets in ArcGIS Experience Builder, excluding list widgets and widgets within list items. This profile allows you to write expressions that generate dynamic content and styles based on the widget's data sources. For dynamic content, the expression is expected to return a value. For dynamic style, the expression should return a dictionary containing supported style properties and their corresponding values.

Context

The following products implement this profile:

Spatial reference

This profile does not include geometry functions and therefore does not need to define a spatial reference for the execution context.

Time zone

The Experience Builder time zone determines the execution context's default time zone.

Profile variables

Variable NameTypeDescription
$dataSourcesDictionaryThe data sources used by the widget.

$dataSources is a dictionary containing key-value pairs, where each key is a data source ID (e.g., dataSource_1-187acf797e1-layer-5-selection). $dataSources has the following properties:

PropertyTypeDescription
layerFeatureSetA reference to a server-side or client-side layer.
queryParamsDictionaryFilters that have been applied to the layer.
selectedFeaturesFeatureSetFeatures that have been selected in the data source.
loadedFeaturesFeatureSetFeatures already loaded in the data source.
loadedFieldsText[]A list of field names representing fields already loaded in the data source.

$dataSources.queryParams is a dictionary containing the following properties:

PropertyTypeDescription
distanceNumberThe distance used for spatial filtering.
geometryGeometryThe geometry used to filter the data source.
geometryPrecisionNumberThe number of decimal places for geometries returned by the query operation.
gdbVersionTextThe version of the geodatabase used for the data source.
groupByFieldsForStatisticsText[]An array of field names used for grouping statistics in the data source.
objectIdsText[]An array of object IDs representing the features in the data source. If specified, the query will only be executed against these features.
orderByFieldsText[]An array of field names used to order or sort the results. Specify ASC (ascending) or DESC (descending) after the field name to control the order.
outFieldsText[]An array of field names to be returned in the data source.
outStatisticsDictionary[]
returnDistinctValuesBooleanIndicates whether distinct values should be returned in the data source.
returnGeometryBooleanIndicates whether the geometry of the features should be returned.
returnMBooleanIndicates whether the M values of the geometry should be returned.
returnZBooleanIndicates whether the Z values of the geometry should be returned.
spatialRelationshipTextThe spatial relationship used to filter the data source (e.g., intersects, contains, crosses, overlaps, touches, etc.).
sqlFormatTextThe SQL format used for the data source (e.g., none | standard | native).
timeExtentDictionaryA dictionary containing the start and end time of the data source's time extent, with keys start and end, both of type Date.
unitsTextThe units used for the distance (e.g., meters, kilometers, etc.).
whereTextSQL where clause used to filter the data source based on attribute values.

Function bundles

Core | Data Access

Return types

Number | Text | Date | DateOnly | Time | Dictionary

If the return value is text, number, or date, the value will be used as dynamic content to display in the widget. If the return value is a dictionary, the dictionary can contain value and styles. Style can change the rendering style of the widget.

For a list of valid dictionary keywords, click here.

Example

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var dataSource = $dataSources['dataSource_1-187acf797e1-layer-5-selection'];
var selectedFeatures = dataSource.selectedFeatures;
var featureCount = Count(selectedFeatures);
var color = '';
var icon = null;

if (featureCount <= 0) {
  color = 'black';
  icon = {
    name: 'Icon 1',
    color: 'white'
  };
} else if (featureCount <= 50) {
  color = 'yellow';
  icon = {
    name: 'Icon 2',
    color: 'blue'
  };
} else {
  color = 'green';
  icon = {
    name: 'Icon 3',
    color: 'red'
  };
}

return {
  background: {
    color
  },
  icon
};

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