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
<SPAN class="keyword token">var</SPAN> fs <SPAN class="operator token">=</SPAN> <SPAN class="token function">FeatureSetByRelationshipName</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Program"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"ProgramName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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?