Select to view content in your preferred language

return field aliases from related tables

1470
3
Jump to solution
11-21-2016 02:58 PM
AndrewBowne
Frequent Contributor

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?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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);
  });
  ...
});

.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

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);
  });
  ...
});

.

AndrewBowne
Frequent Contributor

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yes

0 Kudos