I want to include dynamic content in a text widget in Experience Builder.
I have a feature layer with 1000+ records. I have a field 'quality' with 10 unique values.
I want the dynamic content to display "Values not unique" when no filtering is applied. If filtering is applied (using filter widget), and the filtered records contain only one unique in the the field 'quality', then I want the dynamic content to display the unique value, if not then display "Values not unique".
Is there a way to accomplish this?
Hi @subu ,
The text widget supports Arcade expression in the June 2025 AGOL release.
You can use a similar Arcade script like this:
var ds = $dataSources["dataSource_id"].layer;
var queryStr = $dataSources["dataSource_id"].queryParams.where;
if (IsEmpty(queryStr)) {
return "Values not unique.";
}
else {
ds = Filter(ds, queryStr);
var distinctValue = Distinct(ds, 'field_name');
if (Count(distinctValue) > 1) {
return "Values not unique.";
}
else {
return First(distinctValue).field_name;
}
}
Thanks,
Shengdi
Note that fields used in the widget formatting profile are not automatically added to the used fields list. If you don't use the "quality" field elsewhere, the Arcade script may run incorrectly, resulting in incorrect output.