Select to view content in your preferred language

Arcade syntax different for shapefile vs feature service?

05-15-2023 11:09 AM
Labels (1)
Frequent Contributor II

I've run into an issue here where the same exact expression will be validated and work fine for the shapefile version of a layer, but not the web version. The only difference is the field name (truncated in the shapefile). It's a text field.


Shapefile on right, feature service on left.

It throws an error that the index is out of bounds. Is it just looking at a random feature, seeing a null value, and assuming none of the features have values? For features with no county signed route, in the shapefile, they are just populated with a space. A typical field with a value reads something like 'STATE OF IOWA, Z 16, N' and the Arcade spits out Z16 as its label.


Taking suggestions on how to work around this. Thanks!

0 Kudos
4 Replies
MVP Frequent Contributor

Hmm, I couldn't reproduce that behavior, the syntax does not differ.


A possible explanation could be that your service contains values for which the expression fails, eg null values  or strings without commas, strings where there is no space after the comma.


  • don't split by ", ", just use the comma without space
  • check the length of the split. if it's 1, return a default value (eg the whole string, or an error message)


var f = Replace($feature.TextField2, " ", "")
var f_split = Split(f, ",")
if(Count(f_split) > 1) { return f_split[1] }
return f

Have a great day!
0 Kudos
MVP Frequent Contributor

Yes I think there's some more robust validation happening for the Feature Service input.  I'd go with Johannes's solution.  @Johannes there's still no Try - Except equivalent in Arcade is there?

0 Kudos
MVP Frequent Contributor

Nope still waiting on that one. Related idea:

Have a great day!
0 Kudos
MVP Notable Contributor

I am able to reproduce that error IF there is a value in the label field that is null or does not contain a comma.....

Along with @JohannesLindner stated, you can also put some console() statements in there to see what is actually being returned from the representative row:




0 Kudos