Arcade - Get related information from feature

929
6
Jump to solution
10-11-2022 11:56 PM
Labels (1)
MarcoPoetsch
Occasional Contributor II

Hi there,

I'm trying to get information from a table to a feature based on a related field.
The relationship is defined by a GUID field.


So basically I have a polygon layer called "Parcel" with a field for GlobalID.  Then there is a table ("Permit") with additional information to this parcel. This "Permit" table has a field with ParcelID (= GlobalID from  Parcel). There might be more than one matching permits to a parcel.

Is there a way I can configure the popup of the parcel in such a way that I can get some of the related fields from the permit table?

Just a note: There is no relationship configured (no relationship class has been setup)

 

1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Without a relationship class, you have to do the filtering yourself:

// load the permit table
var all_permits = FeatureSetByPortalItem(...)

// get the permits that belong to the parcel
var parcel_id = $feature.GlobalID
var parcel_permits = Filter(all_permits, "ParcelID = @parcel_id")

// return a default value if no permits were found
if(First(parcel_permits) == null) {
    return "No permits found for this parcel"
}

// build your output
var output = []
for(var p in parcel_permits) {
    var line = `Permit ${p.PermitNumber}, issued on ${p.PermitDate} to ${p.PermitOwner}`
    Push(output, line)
}

// conctenate and return
return Concatenate(output, TextFormatting.NewLine)

Have a great day!
Johannes

View solution in original post

6 Replies
JohannesLindner
MVP Frequent Contributor

Without a relationship class, you have to do the filtering yourself:

// load the permit table
var all_permits = FeatureSetByPortalItem(...)

// get the permits that belong to the parcel
var parcel_id = $feature.GlobalID
var parcel_permits = Filter(all_permits, "ParcelID = @parcel_id")

// return a default value if no permits were found
if(First(parcel_permits) == null) {
    return "No permits found for this parcel"
}

// build your output
var output = []
for(var p in parcel_permits) {
    var line = `Permit ${p.PermitNumber}, issued on ${p.PermitDate} to ${p.PermitOwner}`
    Push(output, line)
}

// conctenate and return
return Concatenate(output, TextFormatting.NewLine)

Have a great day!
Johannes
MarcoPoetsch
Occasional Contributor II

Genius. Thanks!

0 Kudos
DougBrowning
MVP Esteemed Contributor

Anyone know if there are plans to add a where clause to the FeatureSet calls like search cursor and other tools?  I have posted it before but never a response.

The issue I have is some of my layers are 100K+ records.  I know there is only the one record that matches my query but I have to grab all 100K then filter for the 1.  With 30+ expressions in my popup it grinds to a halt.  

Just add the filter to the call like this

FeatureSetByName(featureSetCollection, title, fields?, includeGeometry?, FilterQuery)

It would speed maps way up and maybe even make FeatureSet fast enough to enable it in symbology.

thank you

 

0 Kudos
JohannesLindner
MVP Frequent Contributor

Sounds like a good enhancement, I just kudo'd your idea about this.

I'm not aware of any plans in this regard, but the ESRI staff in the Arcade related ideas isn't very communicative.


Have a great day!
Johannes
Bud
by
Notable Contributor

Can you provide a link to your idea?

DougBrowning
MVP Esteemed Contributor
0 Kudos