AnsweredAssumed Answered

Arcade error when accessing empty feature set

Question asked by don.morrison on Apr 26, 2020
Latest reply on May 8, 2020 by xander_bakker

I'm just starting to use Arcade - like it a lot so far but there is one scenario that I can't figure out. I want to retrieve the set of related records associated with a feature for my ArcGIS Online web map popup. I can do this with this statement

var fs = FeatureSetByRelationshipName($feature, "Program", ["ProgramName"], false);


It works great except when the feature has no related records. I still get a FeatureSet returned, and I would expect it to contain zero features. But any method I use to access the FeatureSet returns "Execution Error:Cannot read property 'toString' of null". I've tried all of the following:

  • Count(fs)
  • for (var f in fs) {}
  • First(fs)

What is the trick to allow me to detect in my code that the feature set is empty?