I have a map service with one layer and three related tables. I can successfully execute queries against my related tables and return values. The problem I am having is that I only get the field names and not their aliases. How can I access field aliases of the tables?
Solved! Go to Solution.
Andrew,
You use the esri request class to get the json for the layer and that will have the fields and aliases array
require([
"esri/request", ...
], function(esriRequest, ... ) {
var layerUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0";
var layersRequest = esriRequest({
url: layerUrl,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function(response) {
console.log("Success: ", response.fields);
}, function(error) {
console.log("Error: ", error.message);
});
...
});
.
Andrew,
You use the esri request class to get the json for the layer and that will have the fields and aliases array
require([
"esri/request", ...
], function(esriRequest, ... ) {
var layerUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0";
var layersRequest = esriRequest({
url: layerUrl,
content: { f: "json" },
handleAs: "json",
callbackParamName: "callback"
});
layersRequest.then(
function(response) {
console.log("Success: ", response.fields);
}, function(error) {
console.log("Error: ", error.message);
});
...
});
.
Am I correct to assume I will have to do this for every related table? Then, store the array and query it by the field name to get the alias?
Yes