Arcade error when using FeatureSet to get related data

1671
4
Jump to solution
04-24-2019 11:44 AM
MitchEast
New Contributor III

I'm working with a feature layer and a separate table that have a column in common (many to one relationship). The feature layer common field name is PropName and the table field name is GIS_PropName. I'm attempting to use FeatureSets to get the value of a second field called WMAName using Arcade. I can get as far as the below but when I change the last line to:

return target.WMAName;

I get the following error. Execution Error:Runtime Error: Cannot call member property on object of this type. WMAName

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

In this case target is a collection of records, which might only have one record. You can do something like this:

var target = First(Filter(tbl, sql));
return target.WMAName;

// or

var target = Filter(tbl, sql);
return target[0].WMAName;

View solution in original post

0 Kudos
4 Replies
XanderBakker
Esri Esteemed Contributor

In this case target is a collection of records, which might only have one record. You can do something like this:

var target = First(Filter(tbl, sql));
return target.WMAName;

// or

var target = Filter(tbl, sql);
return target[0].WMAName;

View solution in original post

0 Kudos
MitchEast
New Contributor III

Thanks Xander. That first method worked.

Mitch East

GIS Specialist 3, Game Management

Wildlife Resources Division<http://georgiawildlife.com/>

O: (706) 557-3270 | M: (678) 787-5627

Facebook<http://www.facebook.com/WildlifeResourcesDivisionGADNR> • Twitter<http://twitter.com/georgiawild> • Instagram<http://www.instagram.com/georgiawildlife>

Buy a hunting or fishing license today!<http://georgiawildlife.com/licenses-permits-passes>

—————————————————

A division of the

GEORGIA DEPARTMENT OF NATURAL RESOURCES

XanderBakker
Esri Esteemed Contributor

I'm glad it worked. Just remember that the filter will return a collection even if the collection contains only a single record. You will have to drill down to the record to be able to query the individual attribute values.

0 Kudos
ahagopian_coj
New Contributor II

Hello!  In Workforce is a related table with assignment types.  I am trying to pull the assignment types description field from this related table into a pop-up.  I am trying to use this code (modified of course) but get an execution error. Any tips you can toss my way would be greatly appreciated!

var tbl = FeatureSetByName($map,"workforce_8b965c8647bc45d79891d13f207335c8 - Assignment Types", ['description']);
var descr = $feature.description;
var sql = "assignmenttype = '" + descr + "'";
var target = First(Filter(tbl, sql));
return target.description;

0 Kudos