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 choice property of a form, which can be associated with a form 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:
- ArcGIS Maps SDK for JavaScript
- ArcGIS Online
- ArcGIS Field Maps
- ArcGIS Maps SDKs for Native Apps
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 Name | Type | Description |
|---|---|---|
| $feature | Feature | Exposes the feature's attributes for use in the expression. |
| $originalFeature | Feature | The previous state of the feature. |
| $editcontext.editType | Text | Indicates whether the edit event is INSERT, UPDATE, DELETE, or NA (not applicable). |
| $layer | FeatureSet | A collection of features in the same layer as $feature. |
| $datastore | FeatureSetCollection | A collection of layers in the same feature service or database as $feature. |
| $featureSet | FeatureSet | A collection of features in the same table as $feature. |
| $map | FeatureSetCollection | A collection of feature service layers in the same map as $feature. |
Function bundles
Core | Geometry | Data Access | Database | Portal Access
Return types
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.
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;