in Web AppBuilder using JavaScript I have been trying to create a drop down list of the fields for a feature brought in through url. I have been coming up with problem at every stage, I even had problem getting just the field name - which I finally got This works great:
var layerUrl = this.config.facilitiesURL;
var layerInfoRequest = esri.request({
url: layerUrl,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layerInfoRequest.then(function (response) {
fieldInfos = array.map(response.fields, function (aField) {
return {
fieldName: aField.name
//visible: true
};
});
for (i = 0; i < fieldInfos.length; i++) {
console.log(fieldInfos[i]);
}
console.log("fieldInfos", fieldInfos[Object.keys(fieldInfos)[0]]); //obj[Object.keys(obj)[0]];