Getting Empty "display Field Name" on Using esri/request

721
7
12-05-2017 09:03 AM
BehrouzHosseini
Occasional Contributor

I am using esri/request function to Solve a geometric Network and retrieve data from an ArcGIS server. This is the code which I am using

require(["esri/request"], function(esriRequest) {
var params = {
 f: "json"
 };
  params.outFields = agsConfig.outFields;
  params.outSR = outSR;
  params.maxTracedFeatures = agsConfig.maxTracedFeatures;
  params.tolerance = agsConfig.tolerance;
  params.flowElements = traceFlowElement;
  //...
 
 function solve(traceSolverType, params) {
  esri.request({
    url: url,
    content: params,
    callbackParamName: "callback",
    load: function (result) {
                     if (result.hasError) {
                        console.log("Error Solve - description: ${errorDescription}");
                   } else {
                   var junctionsResultFeatures = result.junctions;
                   var json = JSON.stringify(junctionsResultFeatures);
                   console.log(json);

      },
       error: function (error) {
 
      }
    });
   }
});

and the output in JSON out put is like below which as you can see the displayFieldName node is empty "". Can you please let me know what I am missing in the request params settings to get the displayFieldName ?

[  
   {  
      "displayFieldName":"",
      "fieldAliases":{  
         "OBJECTID":"OBJECTID"
      },
      "geometryType":"esriGeometryPoint",
      "spatialReference":{  
         "wkid":4326,
         "latestWkid":4326
      },
      "fields":[  
         {  
            "name":"OBJECTID",
            "type":"esriFieldTypeOID",
            "alias":"OBJECTID"
         }
      ],
      "features":[  
         {  
            "attributes":{  
               "OBJECTID":1101
            },
            "geometry":{  
               "x":-88.16815406499995,
               "y":41.79624553800005
            }
         }
      ]
   },
   {  
      "displayFieldName":"",
      "fieldAliases":{  
         "OBJECTID":"OBJECTID"
      },
      "geometryType":"esriGeometryPoint",
      "spatialReference":{  
         "wkid":4326,
         "latestWkid":4326
      },
      "fields":[  
         {  
            "name":"OBJECTID",
            "type":"esriFieldTypeOID",
            "alias":"OBJECTID"
         }
      ],
      "features":[  
         {  
            "attributes":{  
               "OBJECTID":1407
            },
            "geometry":{  
               "x":-88.16725130299994,
               "y":41.796718816000066
            }
         },
         {  
            "attributes":{  
               "OBJECTID":1413
            },
            "geometry":{  
               "x":-88.16639792099994,
               "y":41.79674986500004
            }
         },
         {  
            "attributes":{  
               "OBJECTID":1414
            },
            "geometry":{  
               "x":-88.16511888299999,
               "y":41.79660011900006
            }
         }
      ]
   }
]
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Bengi,

  I don't think you are missing anything. I don't think that value is set for your MapService. You can verify this but just going the Rest endpoint for you map service normally using the url in your web browser and see what the value is.

BehrouzHosseini
Occasional Contributor

Thanks for reply Reply Robert, but can you let me know how to set that value in the MapService? I mean is this configurable on the service?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

  In ArcMap you open the mxd that is used for that map service and in the TOC open the layer properties that you wan to set the Display Field for and set the Display Expression > Field on the display tab.

0 Kudos
BehrouzHosseini
Occasional Contributor

Thanks Robert, but is't this for Fields? I mean what I need to get back is the name of Feature so I can say for example how many Fuses or Transformers been traced but how to set this in Display? 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

???... Do you mean the name of the Feature Layer you are sending the esriRequest to?

0 Kudos
BehrouzHosseini
Occasional Contributor

well this a Geometric Network Tracing Request. I am getting Edges and Junctions which are in the Trace but it is not clear how many of those junctions are Fuses or Transformers? what I was hoping to get is getting the name of Feature like

"displayFieldName":"Transformer",

in above mentioned JSON in return

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bengi,

  If the feature has that as an attribute in the feature attribute table then you can get the displayfield as I outlined before and see if that helps at all. Short of that I don't know if that is possible to get the feature name in the JSON.

0 Kudos