Since version: 1.39

The Form Dynamic Choice profile returns a list of name and code pairs, often created from an external layer or table. The expression is referenced by the choiceExpression property of a formDynamicChoiceInput, which can be associated with a formFieldElement in a form saved to a web map to present a defined list of values for the user to select from, similar to a coded value domain. This profile is used for dynamic choices of forms in ArcGIS Online’s Map Viewer and Web Editor, as well as in applications built with ArcGIS Maps SDK for JavaScript.

Context

The following products implement this profile:

Spatial reference

The spatial reference of the map in which the expression executes determines the execution context's spatial reference.

Time zone

The time zone of the map in which the expression executes determines the execution context's default time zone.

Profile variables

Variable NameTypeDescription
$featureFeatureExposes the feature's attributes for use in the expression.
$originalFeatureFeatureThe previous state of the feature.
$editcontext.editTypeTextIndicates whether the edit event is INSERT, UPDATE, DELETE, or NA (not applicable).
$layerFeatureSetA collection of features in the same layer as $feature.
$datastoreFeatureSetCollectionA collection of layers in the same feature service or database as $feature.
$featureSetFeatureSetA collection of features in the same table as $feature.
$mapFeatureSetCollectionA collection of feature service layers in the same map as $feature.

Function bundles

Core | Geometry | Data Access | Database | Portal Access

Return types

Dictionary

Example

The following expression queries an external table for materials containing "Clay" and returns an alphabetized list of names and density codes as dynamic choices.

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
var materialDensities = OrderBy(
  Filter(
    FeatureSetByPortalItem(
      Portal("https://www.arcgis.com"),
      "1b9f1e1576854593928199fa2b322032",
      0,
      ["material", "density_lbs_f3"],
      false
    ),
    "material LIKE '%Clay%'"
  ),
  "material ASC"
);

var choiceArr = [];

for (var material in materialDensities) {
  var choice = Dictionary();
  Insert(choice, "name", material.material);
  Insert(choice, "code", material.density_lbs_f3);
  Push(choiceArr, choice);
}

var choiceDict = { choices: choiceArr };

return choiceDict;

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