Select to view content in your preferred language

Text box with changing contents/visibility based on attribute of first feature in connected feature layer

111
1
yesterday
Labels (1)
Crinoid
Regular Contributor

Hi there,

I've got an Experience mainly consisting of a map that has one specific polygon feature layer for fire restrictions. The feature layer has a "Restriction Level" field, which contains the domain values Level 1, Level 2, and Level 3. In Map Viewer, there is always a filter (definition query) on this feature layer so that only polygons of one domain value are visible at a time, reflecting whatever level is in effect. To change the active level, I just change this filter in Map Viewer. Then headings on the Experience use Dynamic Content pull the first (random) polygon to list the domain value I've chosen to show, and ta-da, the map title now says, and the map itself now shows, Level 1 fire restrictions.

The feature layer has a nicely formatted popup that appears on the map when you click on polygons in the Experience, to tell you if fires are permitted or restricted in a given area. HOWEVER, the Experience also has a sidebar where I want to describe the specific rules for Level 1, Level 2, and Level 3. Ideally they'd have some formatting (numbered lists with some bold text). I want this sidebar to only list the rules for the level domain value that is currently showing on the map, though. How could I go about doing this? I can't just put the rules in a popup and connect to the popup because the popup is being used for something else. When I connect the text widget to the fire restriction layer data, I haven't had luck doing anything more complex with Dynamic Content that might let me show specific text under specific domain conditions. I thought there was recently some Arcade capabilities added in Experience Builder, but if I try to do Arcade in the Expression field, it just says the expression is invalid.

Do you have any ideas on how I might pull this off? Copilot ran me in circles with various nonexistent settings; I need a smart human!

0 Kudos
1 Reply
ShengdiZhang
Esri Regular Contributor

Hi @Crinoid ,

Inserting an Arcade expression into a text widget should work. The Arcade script should be something like the following:

// Get the features currently selected on the map.
var selectedFeatures = $dataSources["dataSource_id"].selectedFeatures;

// Exit if no features are selected.
if (Count(selectedFeatures) == 0) {
    return "No features selected.";
}

// Retrieve the first selected feature.
// (This script assumes only one feature is processed.)
var selectedPt = First(selectedFeatures);

// Get the level for the selected feature.
var level = selectedPt.PRestictionLevel;

// Return the corresponding level description.
if (level == "Level 1") {
    return "Level 1 is .....";
} else if (level == "Level 2") {
    return "Level 2 is ......";
} else {
    return "Level 3 is ......";
}

 

Please let me know if you have other questions.

Regards,

Shengdi

0 Kudos