Arcade Expression General Function Failure and Sporadic Selection Highlighting

1502
8
01-28-2021 12:03 PM
Labels (2)
DeniseBeckham
New Contributor II

I am trying to customize the pop-up of a polygon layer in ArcGIS Pro with an arcade expression.  I am working on a request to change inspection boundaries to transfer about 200 inspections from one district to another, so I want to create an expression that will show me how many inspection points intersect each district.  I successfully used the following code in the Arcade Playground

 

 

var parcels = FeatureSetByName($map, "Parcels_And_Buildings - Tax Parcels") 
var parcelIntersect = Intersects($feature, parcels)
var parcelCount = Count(parcelIntersect)
return parcelCount

 

 

However, when I tried to add it as an expression for the pop-up of the inspection layer (with appropriate adaptations), I got the message "Invalid expression. Error on line 3. General function failure." 

Going off of the message, it sounds like there is a problem with the count function. (I had originally nested the functions inside each other and then separated them to try to isolate the problem.)  Has anybody else had a problem like this that they were able to solve? Could it be because there are roughly 600 points intersecting the polygon?  

I also selected one of the districts and then tried doing a select by location on the points for the selected district.  By comparing the results to what I got in ArcMap, I think it selected all the right points, but for some reason, the highlights are all over the place.  It's really odd, because when I tell it to zoom to the selection, it zooms in to the selected district, but it doesn't show any of the points as being highlighted anymore.  

Point highlights are scattered everywhere instead of being inside the selected districtPoint highlights are scattered everywhere instead of being inside the selected district

I am on version 2.7, and I checked to make sure that I have the most current version.  The points are being pulled from a SQL view.  I am still adjusting to Pro.  I've been trying to switch over, but if I can't get these issues straightened out, I guess I'll have to go back to ArcMap for this project.  

0 Kudos
8 Replies
jcarlson
MVP Esteemed Contributor

Are these layers coming from a hosted feature service?

When I attempt a similar expression with features hosted in my own portal / server, I get a network error at the point in my expression when I call the Count function.

When attempting with file-based feature classes, however, the expression evaluates fine.

jCarlson_0-1611865774448.png

 

Perhaps someone on ESRI staff can confirm, but I would guess that there is a mismatch between what the Count function does in 2.7 and what prior portal versions do, such that the command cannot return successfully.

- Josh Carlson
Kendall County GIS
DeniseBeckham
New Contributor II

Hi Josh, 

The layers I'm using are not services.  The district polygons are coming from a file geodatabase, and the points are coming straight from a SQL database.  

Thanks,
Denise

0 Kudos
jcarlson
MVP Esteemed Contributor

Very curious! Is there a difference in projection or datum between the two?

- Josh Carlson
Kendall County GIS
0 Kudos
DeniseBeckham
New Contributor II

Hmm, I just checked, and they're both in WGS 1984, as is the data frame.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @DeniseBeckham ,

 

The only reason I can come up with to have this type of selection behavior would be multi point features. If possible could you export a selection of the SQL database point to a local FGDB and try if it provides the same selection result?

DeniseBeckham
New Contributor II

Hello Xander, 

There aren't any multipoint features in this layer.  It's coming from a view that our programmer made that pulls from about 5 different tables.  The locations are created from the lat/long values in one of the tables. 

As you suggested, I selected some of the points and exported them.  I selected a rectangle on the map, and the highlights were all over the place again. 

Selection highlights are scattered even though I selected with a rectangleSelection highlights are scattered even though I selected with a rectangle

However, when I exported them into the project geodatabase, all the points in the resulting feature class were within the rectangle I drew.  And when I selected by location from my export, the highlights also showed up properly.  

The points exported were all within the rectangle I drew, and the selection highlighted properlyThe points exported were all within the rectangle I drew, and the selection highlighted properly

Furthermore, I just tried my arcade expression again.  I changed it to reference the points I exported, and it worked perfectly! I'm now really confused as to why it won't work with the live data.  I'd hate to have to export all the points every time I want to use arcade expressions when I'm working with SQL data in Pro. The view is a little slow. Could that have something to do with it? 

Thanks,
Denise

0 Kudos
jcarlson
MVP Esteemed Contributor

Double check the view query, if you have access to the SQL behind it. It sounds like maybe it doesn't a consistent unique identifier column to reference, so when it selects "ObjectID 100", there might be multiple that it's grabbing by mistake.

If you have access to the database, you could also add the points as a Query Layer so that Pro can validate the SQL beforehand, and select multiple columns as unique identifiers.

When you export those features, it would have created its own internal ObjectID to uniquely identify rows in the exported feature class, which might explain the difference.

- Josh Carlson
Kendall County GIS
DeniseBeckham
New Contributor II

Hi Josh, 

I do have access to the SQL database.  The layer in Pro uses the RECORD_ID field (which is a string of two letters followed by 7 numbers) as the unique identifier column.  I did a few different simple queries of the view in SQL and confirmed that the Record IDs are definitely unique in this view.  

I also tried adding a new query layer from the Add Data button on the ribbon and selected fewer columns.  I made sure to choose the RECORD_ID column as the unique identifier, but the new layer exhibited the same unexpected highlighting behavior and the arcade expression didn't work when I referenced the new layer. As I mentioned earlier, select by location works perfectly fine on the exact same view in ArcMap.  

Thanks,
Denise

0 Kudos