BACKGROUND
I’m running into an issue with a Group Filter in Experience Builder that uses multiple data sources, all of which share a common field of National Forest Name. The filter uses the contains operator with predefined unique values. I’m using contains because some data sources store multiple forest names in a list. I set a single default value (Allegheny National Forest) and intentionally removed the “All” option so only one forest loads by default. The filter is also set to “Apply this filter automatically.”
Later in the app, I reference one of these filtered data sources (dataSource_15-0) in a text widget. The text widget runs an Arcade expression that compares two fields and returns “increase,” “decrease,” or “no change.” The intent is for the expression to evaluate the National Forest that is selected in the filter dropdown list.
THE ISSUE
If I select any forest other than the default, the Arcade expression fails with this error:
Test execution error: Execution error - Cannot access property of null object. Verify test data.
When I inspect the data source using Console() messages, it appears that the FeatureSet only contains one feature—always the default forest value—even though the queryParams.where correctly reflects the forest I selected in the filter. The loaded features do show the correct forest name, but the FeatureSet being passed into Arcade still contains only the default-value feature.
If I change the default predefined value to a different forest, the same behavior occurs: the data source always resolves to the default value, even when the filter selection changes.
Is this a bug related to using a default predefined value in the Group Filter, particularly in how it influences the FeatureSet returned by getFilteredFeatureSet()? Or is there a configuration detail I may have overlooked?
CODE
// Create variable for return text
var return_text;
// FUNCTION: get the filtered feature set of a data source
function getFilteredFeatureSet(ds) {
var result = ds.layer;
Console("INSIDE getFilteredFeatureSet() FUNCTION: ")
Console("Initial 'result' Count(datasource.layer): " + Count(result))
var sql = ds.queryParams.where;
Console("SQL on 'result': " + sql)
// If the data has a query on it, apply it to the data set
if (!IsEmpty(sql)) {
Console("SQL Not Empty - Filter() result using sql")
result = Filter(result, sql);
}
// if NO Filter -- Default Filter to Allegheny NF
else if (IsEmpty(sql)){
Console("Default Filter to Allegheny NF")
result = Filter(result, "Unit_Name LIKE '%Allegheny National Forest%'");
}
// return the filtered Feature Set
Console("'result' FeatureSet Count after Filtering: " + Count(result))
return result;
}
// Summary Table - Get Filtered FeatureSet
Console('BEFORE getFilteredFeatureSet() CALL: ')
Console("\tCount(dataSource_15-0.layer): "+ Count($dataSources["dataSource_15-0"].layer))
Console("Query Params Before: "+ $dataSources["dataSource_15-0"].queryParams.where)
Console("Loop dataSource_15-0 feature set and print Forest Name : ")
for (var f in $dataSources["dataSource_15-0"].layer){
Console(f['Unit_Name'])
}
Console("Loop Through Loaded Features : ")
for (var f in $dataSources["dataSource_15-0"].loadedFeatures){
Console(f['Unit_Name'])
}
var Summary_Table_FILTERED = getFilteredFeatureSet($dataSources["dataSource_15-0"]);
// access the wui area fields
var WUI_2010 = First(Summary_Table_FILTERED)['wui_area_10_km']
var WUI_2020 = First(Summary_Table_FILTERED)['wui_area_20_km']
if (WUI_2020>WUI_2010){
Console("Increase in WUI")
return_text = "increase"
}
else if (WUI_2020 == WUI_2010){
Console("No Change in WUI")
return_text = "no change"
}
else if (WUI_2020<WUI_2010){
Console("Decrease in WUI")
return_text = "decrease"
}
else{
return_text = "ERROR CALCULATING CHANGE IN WUI"
}
return {
value: return_text,
text: {
size: 16,
color: 'rgba(44, 112, 145,1)',
bold: true,
},
};