What is the correct Arcade syntax when using ArcGIS Pro?

2291
4
Jump to solution
12-22-2020 07:51 AM
Labels (1)
JasonBennett
New Contributor II

I originally started writing Arcade expressions in ArcGIS Online. Today I attempted to write an expression in Pro 2.6 with the intention of updating a webmap. I get errors in the Expression Builder that I don't get using AGOL. In ArcGIS Pro, the error states "Invalid expression. Error on line 1. Colon expected."

error.png

However, this expression works fine on the web version.

Capture.JPG

Why don't these work the same? Where does this colon go?

0 Kudos
1 Solution

Accepted Solutions
JasonBennett
New Contributor II

Thanks for the suggestion.

As it turns out, it doesn't care about the syntax for HH_Status. That works with both dots and square brackets. But Manhole_Type inside curly brackets was the violation.

 

if ($feature["HH_Status"] == 0) {return "Proposed " + $feature.Manhole_Type}

 

Edit: For my purposes, this worked:

if ($feature["HH_Status"] == 0) {return "Proposed " + DomainName($feature,"Manhole_Type")}

 

View solution in original post

4 Replies
JoeBorgione
MVP Emeritus

I think the difference is how you are referencing the feature attribute:

 

if($feature["HH_STATUS"] == 0)

// try replacing with:

if($feature.HH_STATUS == 0)

 

 

That should just about do it....
JoshuaBixby
MVP Esteemed Contributor

Joe, I don't think that is the issue, or should be.  According to Esri's own documentation: Structure And Logic | ArcGIS for Developers

Attribute values can be referenced using the . syntax or with square brackets.

If changing between dot and bracket does change the result, then it is a defect.

JoeBorgione
MVP Emeritus

Hence  'think' in italics.  I've never written arcade for anything but Pro, and always used the $featureDotAttribute syntax...

That should just about do it....
0 Kudos
JasonBennett
New Contributor II

Thanks for the suggestion.

As it turns out, it doesn't care about the syntax for HH_Status. That works with both dots and square brackets. But Manhole_Type inside curly brackets was the violation.

 

if ($feature["HH_Status"] == 0) {return "Proposed " + $feature.Manhole_Type}

 

Edit: For my purposes, this worked:

if ($feature["HH_Status"] == 0) {return "Proposed " + DomainName($feature,"Manhole_Type")}