Passing attribute value as a variable with ArcGIS JavaScript

06-21-2017 03:14 PM
New Contributor II

I want to get the value of an attribute when a user clicks on a feature. Building off this example: Does anyone know how I can, for example, get the value for DomOrd in the layer Soil Survey Geographic? The following code snippet is from the above example.

 if (layerName === 'Soil Survey Geographic') {
//the following two lines are similar to what I want, but they don't work
var attributeVal = result.layerName.DomOrd; 
feature.popupTemplate = { // autocasts as new PopupTemplate()
title: "{Map Unit Name}",
content: "<b>Dominant order:</b> {Dominant Order} ({Dom. Cond. Order %}%)" +

I need to pass the attribute value in an SQL query with ColdFusion - so that's why I need the value.

#arcgis javascript 4.3

Tags (1)
0 Kudos
1 Reply
MVP Honored Contributor

Here's how to get the value from the field DomOrd. You have to use the field alias to get it

var attributeVal = feature.attributes["Dominant Order"];