Dear AGOL community,
In my Experence Builder app I currently have my map which displays a polygon layer, a List Widget, and an Edit Widget (see screen grab 1). My List Widget is set up so that when I select a value/row in the list, it filters the corrosponding related values in my polygon dataset (see screen grab 2).
My Edit Widget is set up to edit a second layer (lines). When creating new line features, I would like to automatically populate (or make default) one of the fields in my line layer (TAXONID) with the same selected TAXONID value from my List Widget (see screen grab 3).
Hoping someone can advise how I might do this please.
Regards, Damian
Hi @Damian
are you saying that you would like to populate the field on the (line) form based on an attribute in another (polygon) layer? If so you can do that by using an Arcade expression in the form.
See this article on using FeatureSet expressions in forms for more info.
Thanks @EmilyGeo ,
I wrote the very simple Arcade Expression below. Unfortunatly it only returns the value of my first record in my entire polygon dataset, not the filtered record in my polygon dataset (see screen grab 4 - the value should be '10012' not '10015'). I tried other things with my List Widget such as selecting records rather than filtering, however it made no difference. Is there anyway to return a filtered value?
var layerName = "Distribution Polygons";
var fieldName = "TAXONID";
var firstFeature = First(FeatureSetByName($map, layerName));
return firstFeature[fieldName];
Regards, Damian
A further update...
A did a tiny tweak to my Arcade expression and now it works. I have no idea why 🤔
Code below...
var layerName = "Distribution Polygons";
var fieldName = "TAXONID";
var layer = FeatureSetByName($map,layerName);
var firstFeature = First(layer);
return firstFeature[fieldName];