Select to view content in your preferred language

An error occurred when starting a widget embedded within InfoWindow: Cannot read property '1' of null

2696
2
11-04-2015 01:39 PM
TrevorMasters
Occasional Contributor

I am getting the above error (init.js:919 API v3.14) identifying a feature in a javascript map viewer, when calling `infoWindow.setFeatures(featureSet);`. The problem is caused by a map service having field aliases with trailing colons in them. The following is part of the json returned from the map service query (geometry removed).

I can see the problem, but not sure how to go about fixing it? Is it caused by the json deserialization, serialization by the REST API (10.3.1 server), or a bug in the javascript API?

If I only choose outfields that have no trailing colon, it works. I have no control over the offending map service.

  {
"results":[{
  "layerId":37,
  "layerName":"Waste Water Lateral",
  "displayFieldName":"Unit ID:",
  "value":"NP-MANGO0131SL/1",
  "attributes":{
  "OBJECTID":"2474425",
  "Depth":"0.6",
  "SHAPE":"Polyline",
  "Install":"Null",
  "Unit ID:":"NP-MANGO0131SL/1",
  "Owner:":"W&W",
  "Asset ID:":"115807",
  "Comments:":"Null",
  "NPDC_VECTOR_SDEADMIN_SVEW_WWLATERAL_area":"NP",
  "SHAPE_Length":"8.117518"
  },
  "geometryType":"esriGeometryPolyline"

// geometry removed
  }
}]

0 Kudos
2 Replies
FrankJohnson
Deactivated User

Im not sure if your JSON code is bad or you pasted part of the code you have. Your closing bracket is in the wrong position.

//geometry removed

} ]

}  -- This is closing the top of the code.. you have it inside the results declaration. Move it and see if you still get the error.

0 Kudos
TrevorMasters
Occasional Contributor

Sorry, It is my copy/paste that is incorrect - I tried to simplify the example by removing lines, and adding newlines. The key thing is the trailing colon (:) in any field name. The response Json looks correct (e.g. "Comments:":"Null") but this gets interpreted as "Comments"::"Null".

0 Kudos