I have a feature layer connected to a WAB map, with the following fields
Utilizing the Feature Layer Object, is there any simple way to get a list of the field names? I'd rather not run a Query, but if I have to what is best way to only return 1 record with those field names?
Thank you for your time
Solved! Go to Solution.
Joe,
Are you waiting for the FeatureLayer to load before you are checking the fields?
centerlineFeatureLayer.on("load", function(){
console.info(centerlineFeatureLayer.fields);
});
Joe,
A FeatureLayer has a fields property:
FeatureLayer (legacy) | API Reference | ArcGIS API for JavaScript 3.18 | fields
I tried accessing that object, Fields is null.. here is the logic (I confirmed the selectedCenterlineUrl is corrrect):
var selectedCenterlineUrl = this.HierarchyTableCenterlineSelect[this.HierarchyTableCenterlineSelect.selectedIndex].value;
var centerlineFeatureLayer = new FeatureLayer(selectedCenterlineUrl);
centerlineFeatureLayer gets created but fields is null..Why?
Joe,
Are you waiting for the FeatureLayer to load before you are checking the fields?
centerlineFeatureLayer.on("load", function(){
console.info(centerlineFeatureLayer.fields);
});
Robert, thank you so much. This saved me hours of frustration and produced the intended result!
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.