AnsweredAssumed Answered

Arcade: How do I use a variable as the field list parameter for FeatureSetById?

Question asked by rblash on Oct 25, 2019

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

'ParentTapNumber', 'CustomerName', 'CustomerContact'

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.

 

//Set the name of the related table, foreign key field, and attributes to include in the feature set
var relTable = "MyTableName_5212"
var relKey = "ParentTapNumber"
var relAtts = "'CustomerName', 'CustomerContact'"
var relFSAtts = "'" + relKey + "', " + relAtts
console(relFSAtts)

// Get feature attributes from parent table and build query to get related records
var featID = $feature.TapNumber;
var featQry = relKey + " = '" + featID + "'";

// Get feature set from related table based on ID in map, and filter it with the query
var fSet = FeatureSetById($map,reltable,[relFSAtts]);
var fSetFilt = Filter(fSet, featQry);

//Declare placeholder variables for each attribute, and declare utility variables
var CustomerNameResult;

Outcomes