Populate edit layer with value from selected row in list widget

577
4
01-10-2024 05:31 PM
Damian
by
New Contributor III

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

0 Kudos
4 Replies
EmilyGeo
Esri Contributor

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.

0 Kudos
Damian
by
New Contributor III

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

0 Kudos
Damian
by
New Contributor III

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];

 

 

 

EmilyGeo
Esri Contributor

I'm glad you were able to get it working 😊 In reference to your question about filtering, yes there are ways you can filter the data including using the Filter function. This blog post by Alix is a great resource on how to set up an expression in a form to get a filtered value. 

0 Kudos