I'm trying to pass a variable for the fieldList parameter of the FeatureSetById function. See line 13.
If I remove [relFSAtts] from line 13 and return all fields, my script works fine. But when I use a variable in an attempt to retrieve only some fields, no featureset is returned.
My console output looks correct, so I'm not sure why it's not working
<SPAN class="string token">'ParentTapNumber'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CustomerName'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CustomerContact'</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Any ideas on how to make this work? I want to avoid hard-coding attributes where possible, because this is a script I'll use frequently.
<SPAN class="comment token">//Set the name of the related table, foreign key field, and attributes to include in the feature set</SPAN>
<SPAN class="keyword token">var</SPAN> relTable <SPAN class="operator token">=</SPAN> <SPAN class="string token">"MyTableName_5212"</SPAN>
<SPAN class="keyword token">var</SPAN> relKey <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ParentTapNumber"</SPAN>
<SPAN class="keyword token">var</SPAN> relAtts <SPAN class="operator token">=</SPAN> <SPAN class="string token">"'CustomerName', 'CustomerContact'"</SPAN>
<SPAN class="keyword token">var</SPAN> relFSAtts <SPAN class="operator token">=</SPAN> <SPAN class="string token">"'"</SPAN> <SPAN class="operator token">+</SPAN> relKey <SPAN class="operator token">+</SPAN> <SPAN class="string token">"', "</SPAN> <SPAN class="operator token">+</SPAN> relAtts
<SPAN class="token function">console</SPAN><SPAN class="punctuation token">(</SPAN>relFSAtts<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">// Get feature attributes from parent table and build query to get related records</SPAN>
<SPAN class="keyword token">var</SPAN> featID <SPAN class="operator token">=</SPAN> $feature<SPAN class="punctuation token">.</SPAN>TapNumber<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> featQry <SPAN class="operator token">=</SPAN> relKey <SPAN class="operator token">+</SPAN> <SPAN class="string token">" = '"</SPAN> <SPAN class="operator token">+</SPAN> featID <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Get feature set from related table based on ID in map, and filter it with the query</SPAN>
<SPAN class="keyword token">var</SPAN> fSet <SPAN class="operator token">=</SPAN> <SPAN class="token function">FeatureSetById</SPAN><SPAN class="punctuation token">(</SPAN>$map<SPAN class="punctuation token">,</SPAN>reltable<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN>relFSAtts<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> fSetFilt <SPAN class="operator token">=</SPAN> <SPAN class="token function">Filter</SPAN><SPAN class="punctuation token">(</SPAN>fSet<SPAN class="punctuation token">,</SPAN> featQry<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Declare placeholder variables for each attribute, and declare utility variables</SPAN>
<SPAN class="keyword token">var</SPAN> CustomerNameResult<SPAN class="punctuation token">;</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>