[GIS] Filtering an ArcGIS Feature Service by Related Table

arcgis-javascript-apifeature-service

With a feature service that has a related table, is there a way to set a definition expression using the fields in the related table? For example, with the feature service located at https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0, is it possible to create a definition expression that would only show me Incidents that had an Incident Priority record more recent than a certain date?

Best Answer

if you snoop the network traffic in this sample, you'll see that additional queries for the attributes of related records aren't made until an individual feature has been clicked. this is because only the attributes present in the feature service itself are available automatically for filtering.

as an alternative, you could:

  1. query the table of related records for rows that satisfy your condition
  2. use the results to generate a list of associated objectids
  3. use the list of object id's for filtering your feature layer with geometry