Arcade accessing table in feature service not working

728
3
Jump to solution
05-07-2020 06:36 AM
Mark_Johnson
New Contributor II

AGS/Portal 10.7.1

New to Arcade.

I've published an image service (with features enabled so I also get a feature service) containing a parcel polygon layer, a polygon layer of City Lots, and a table with Owners info. Data is referenced from a registered geodatabase. The popup for Parcels I successfully configured in Arc Pro doesn't work in Portal so I added the feature layer to a map and have been trying to fix the Arcade expressions. I have one expression successfully intersecting Parcels and City Lots returning city lot numbers, but the one where I try to "join" Owners to Parcels isn't working. I used this Esri blog as a starting point.

// Parcel number of the selected feature in Parcels layer
var ppn = $feature.PPNUMBER
Console("ppn: " + ppn)
// Access the Owners table in the feature layer
var fs = FeatureSetByName($datastore,"Parcel Owners")
Console("fs: " + fs)
Console("Count before filtering: " + Count(fs))
Console("ppn: " + ppn)
// SQL statement for selecting Owners table records by parcel number
// PPN_ is the parcel number field in Owners table
var filterStatement = "PPN_ = @ppn"
Console('filterStatement: ' + filterStatement)
// Filter Owners table to only parcel numbers matching the current parcel
var owners = Filter(fs, filterStatement)
Console("filtered count: " + Count(owners))
Console("filtered owners: " + owners)
// For testing purposes, get the first filtered Owner table record
// Future for loop to get all owner names
var o = First(owners)
Console("first owner: " + o)
// Console("filtered owners count: " + Count(owners))
return o‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The console output says it starts with 15976 owner records, which matches what I see in the table, then filters it down to one matching record, but "o" always returns Null and if I try to access fields with like "o.L_NAME" or "o[L_NAME]" it errors with "Execution Error:Runtime Error: Cannot call member method on null."

Console output

 Results output

I've also tried filtering "fs" with Top instead, and hard coding a parcel number I know has multiple owner records. I've also tried returning "owners" and get an empty FeatureSet.

Results returning owners variable

It's like even though Count is saying there's records in the FeatureSet it's actually always Null/empty.

There's a relate between Parcels and Owners too, but I'm not trying to access it that way and I don't see a way to do it with what's available in the expression builder.

0 Kudos
1 Solution

Accepted Solutions
Mark_Johnson
New Contributor II

Esri Support confirmed there's a bug (BUG-000127655) in 10.7.1, but is working in 10.8.

View solution in original post

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Mark Johnson ,

I don't see anything wrong with your expression and the fact that you have a record after filtering the data should allow you to access the attributes. The only thing I see is that your field name contains an underscore and for accessing the data you would use o["L_NAME"] and not o[L_NAME] or o.L_NAME, but I guess that was a typo.

Did you contact Esri Support? I think to be able to resolve this issue access to the data and the environment is important.

0 Kudos
Mark_Johnson
New Contributor II

Esri Support confirmed there's a bug (BUG-000127655) in 10.7.1, but is working in 10.8.

0 Kudos
acharko
New Contributor II

How do you display the returned results from the expression in the pop-up?
We were able to use the code to return info from a table, but when we add the expression to the field list, it's showing it as an object. We want to just select two to three fields from the expression to display in the popup.

0 Kudos