I have the following code working, but I need to return the value of the resultant "fieldInfos" string to the createFieldInfos() function and I'm not sure how to do that. Can anyone point me in the right direction?Thanks,Joanfunction createFieldInfos() {
console.log("-->inside createFieldInfos function");
var endpoint = "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer/0";
var jsonobject = esri.request({
url: endpoint,
content: { f: 'json' },
callbackParamName: 'callback',
load: processServiceInfo,
error: errorHandler
});
console.log("jsonobject: " + jsonobject);
}
function processServiceInfo(info) {
console.log('layer info: ', info);
console.log("info.name: " + info.name + ",info.id: " + info.id);
var fieldInfos = "";
fieldInfos += "[";
dojo.forEach(info.fields, function(field) {
console.log( "Name: " + field.name + ", Alias: " + field.alias);
if (field.name != "Shape" & field.name != "OBJECTID") {
fieldInfos += "{'fieldName': '" + field.name + "',";
fieldInfos += "'label': '" + field.alias + "',";
fieldInfos += "'visible':" + true + "},";
}
});
fieldInfos += "],";
console.log("fieldInfos: " + fieldInfos);
}
function errorHandler(err) {
console.log('error: ', err);
}