Select to view content in your preferred language

how to read a field from a featureset

755
1
Jump to solution
04-14-2022 02:58 AM
BertKraan1
Frequent Contributor

In my smartform I want to read a field ("naam") from a featureset so I can use that to enter in my new feature.

I managed to select the correct feature from the featureset by it's geographical location:

// Get name from underlying buffer
var feature1 = $feature
var geometry2 = FeatureSetByName($map,"Wildweiden PairwiseBuffer")

var intersectBufferFS = Intersects(feature1, geometry2)

return intersectBufferFS

which results in:

BertKraan1_1-1649930278768.png

Now, how do I extract the third field 'naam' to a string?

 

thanks for your time,

 

Bert

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Your expression is returning a feature set. You probably want to use the First function to get the first feature in the intersection result (assuming there's only one or fewer). You also may want to handle the case where the feature does not intersect anything, you can use IsEmpty for this.

So it should be similar to this:

// Get name from underlying buffer
var feature1 = $feature
var geometry2 = FeatureSetByName($map,"Wildweiden PairwiseBuffer")

var feature = First(Intersects(feature1, geometry2))
if (IsEmpty(feature)) {
    return null
} else {
    return feature["naam"]
}

 

View solution in original post

1 Reply
by Anonymous User
Not applicable

Your expression is returning a feature set. You probably want to use the First function to get the first feature in the intersection result (assuming there's only one or fewer). You also may want to handle the case where the feature does not intersect anything, you can use IsEmpty for this.

So it should be similar to this:

// Get name from underlying buffer
var feature1 = $feature
var geometry2 = FeatureSetByName($map,"Wildweiden PairwiseBuffer")

var feature = First(Intersects(feature1, geometry2))
if (IsEmpty(feature)) {
    return null
} else {
    return feature["naam"]
}