Select to view content in your preferred language

Arcade Expression works in Pro but not in ArcGIS Online

381
3
05-31-2024 05:58 AM
GISAdmin7
Occasional Contributor

I have an expression that I use in ArcGIS Pro to symbolize features based on the amount of days away from their expiration dates. 

ROW Agreements Arcade.png

However, when I try to use this same expression in ArcGIS Online I get a message that says "Error There Was An Error". What's causing the error?

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

Hard to say, the expression looks fine to me. Why does the expiration date have to be wrapped in the Date function, though? Is the field not actually a DateTime type? Could be there's a value in that field that the Date function doesn't like, and it's throwing an error in AGOL.

I have noticed that Pro validates an expression based on a subset of features, not the whole layer. So Pro might say the expression is okay, but it hasn't actually validated it against whatever that bad value is.

Maybe try switching to bracket notation, see if that makes a difference?

$feature['EXPIRATION_DATE']

- Josh Carlson
Kendall County GIS
0 Kudos
GISAdmin7
Occasional Contributor

It is a datetime field. Oddly enough, removing the date function and using bracket notation still returns the same error. It appears to work when I hit Run above the expression, but then returns the error when I hit Done to save the expression. 

0 Kudos
jcarlson
MVP Esteemed Contributor

Review the entire field. Any bad values in there?

Maybe try nesting the entire expression in another conditional check:

if (IsNull($feature.EXPIRATION_DATE)) {
  return 'No Date Value'
} else if (DateDiff(Date($feature.EXPIRATION_DATE), Now(), 'days') <= 90) {
  return 'Expiration Soon / Expired'
} else {
  return 'Active'
}
- Josh Carlson
Kendall County GIS
0 Kudos