Select to view content in your preferred language

layer.definitionExpression after applyEdits

446
1
Jump to solution
04-20-2022 12:01 PM
rbossio
Emerging Contributor

I create a feature layer programmatically by setting the source, add to web map, and all displays fine. I then update some feature attributes in that layer programmatically by using applyEdits. All this seems to be working correctly. When I click on the feature to display the popup, I see the attribute values are all updated. However, if I try to use definitionExpression to filter on the updated attributes, it does not return any results. In debugging and viewing the layer source items, those attributes do not have the updated values. 

Note that the code to filter on attributes I am not changing works. (i.e. features matching the query are visible, and those that do not are hidden).

I'd like to be able to filter features in my layer using the updated attribute values after an applyEdits. Is this not possible with the definitionExpression? Any advise on how I could do that?

Thanks.

1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Can you please provide a simple reproducible case? I set up a simple test app and I am not able to reproduce issue. But perhaps I may have misunderstood your issue. 

In the following test app, I am creating a feature collection and set the definitionExpression. Then from update attributes button, I change the attributes of two features. Layer is updated correctly show the features that only meet the definitionExpression. https://codepen.io/U_B_U/pen/wvpObbJ?editors=100

View solution in original post

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

Can you please provide a simple reproducible case? I set up a simple test app and I am not able to reproduce issue. But perhaps I may have misunderstood your issue. 

In the following test app, I am creating a feature collection and set the definitionExpression. Then from update attributes button, I change the attributes of two features. Layer is updated correctly show the features that only meet the definitionExpression. https://codepen.io/U_B_U/pen/wvpObbJ?editors=100

0 Kudos