Select to view content in your preferred language

Arcade in ArcGIS Online being having issue with understanding 'None'

145
2
12-03-2024 05:42 PM
Labels (1)
HanZheng
Occasional Contributor

I wrote an Arcade expression in ArcGIS Pro to do symbology by unique value, which involves checking if my attribute "value" is empty.

Given that I was deeply influenced by Python syntax, I originally wrote something like below

if (value=None) {...} else {...}

This seems to work in ArcGIS Pro, but ArcGIS Online is having issue interpret this and therefore generated no symbology at all. However, my ArcGIS Online doesn't seem to take it very well until I rewrite this to be:

if (IsEmpty(value)) {...} else {...}

Does Arcade in ArcGIS Online use slightly different syntax compared to ArcGIS Pro?

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

To answer your question, yes, AGOL and Pro have slightly different flavors of Arcade. Also, "None" is actually a function in Arcade, you'll want to write "null". Oh and a single equals sign assigns a value to the variable.

There's no reason you couldn't do "if (value == null){…} else {…}".

- Josh Carlson
Kendall County GIS
ODWC_GIS
Frequent Contributor

var MyLine = When(!IsEmpty($feature.CuArea),$feature.CuArea+" cubic meters","No Volume was recorded for this record.")

//If using the Arcade PopUp Text Element, can display the above easily using:

`${MyLine}`

I recently took a half-day seminar in more efficient Arcade writing. 

The When(!IsEmpty(xyz),ttt,eee) syntax was ubiquitous.

  • The field you want to check for a value is xyz.
  • If xyz is Not Empty, the text ttt is returned.
  • If xyz is Empty, the text eee is returned.

 

0 Kudos