Why does variable string query outFields fail for FeatureLayer?
Example:
var queryFields = "FIELD1,FIELD2";
const query = mapLayerView.createQuery();
query.outFields = [queryFields]; This works!const queryFeatureLayer = new FeatureLayer({
url: url,
outFields: ["FIELD1", "FIELD2"]
// outFields: [queryFields] This will return error below
});
Error
esri.layers.support.fieldProperties] field-attributes-layer:invalid-field Invalid field FIELD1,FIELD2 found in outFields {layer: v, outFields: Array(1)}
Solved! Go to Solution.
Hi there,
Both FeatureLayer.outFields and Query.outFields expect string of arrays. Query.outFields accepting string of field names is not supported in the JS API and is working accidentally. 🙂
Hi there,
Both FeatureLayer.outFields and Query.outFields expect string of arrays. Query.outFields accepting string of field names is not supported in the JS API and is working accidentally. 🙂