Ability to Read Related Table Arcade Expressions in Custom Attribute Displays

543
7
02-24-2021 02:31 PM
Status: Open
by Anonymous User
Not applicable

I have a point feature with a related inspection table that is a one to many relationship.  I want to be able to reference values in the related table and pass them to survey123 via a custom URL.  I'm able to create a custom attribute expression to get the values I need in ArcOnline.  But when I try to access the attribute expressions values or incorporate them into a Custom URL to pass to survey123, I'm unable to.  Specifically I need to be able to use the FeatureByName function in field maps/collector.

 

Below is the custom attribute expression I'm using to pull the most recent inspection data.  I then reference the custom attribute in a custom URL to pass the data to Survey123.  It functions perfectly if I use a browser and open the pop up there, but when opening the popup in the apps, it gives me 0s or errors. I'd love for this to function in Field Maps or Collector.  

var sql = "FACILITYID = '"+$feature.FACILITYID + "'";
var tbl = Filter(FeatureSetByName($map,"pumpstation_gdb - PumpStationinspection"), sql)

if ((Count(tbl))==0) {
    return "no records found"
}
else {
    return First(OrderBy(tbl, 'REPDATE DESC')).H2OLEV
}

 

 

Below is more detailed info on what I was trying to do with the script.

Solved: Re: How to create an arcade expression to show mos... - GeoNet, The Esri Community

7 Comments
ChrisDunn1

Hi Katie,

You've actually found a bug - the FeatureSetByName function is supported in Field Maps but it currently does not work when it is referencing a table, it only works when referencing another feature layer. It is slated to be fixed in an upcoming release.

In the meantime, FeatureSetByRelationshipName will work to pull results from a related table. This expression will return the records that are related to the feature you select, so you won't need to include the sql variable as a filter.

I hope this helps.

Chris

GarethBaker1

I've just run into similar problems with ArcGIS Enterprise 10.8.1. I have four separate attribute expressions set up which make use of FeatureSetByName. They all just look in another (point) layer in the map to return some info.  Work perfectly in the browser but then in Field Maps iOS client only one of them returns a value. The Arcade code is identical in each expression except for different field names that they return.

Example in browser

GarethBaker1_1-1614242610345.png

Same record in Field Maps

GarethBaker1_0-1614243105255.png

 

 

DougBrowning

I am looking up 20 different variables from another layer and they all work.  Weird.

I did find a bug where if you give it a field list it will not work.  Must use * or nothing.

var sql = "PointID = '" + $feature.PointID + "'";
var tbl = Filter(FeatureSetByName($map,"Points", ["*"], false), sql);
return First(tbl).DesignLat

I have also talked to the team about fixing the built in relationship values.  That would be way easier but they have not worked in a long time.   Should not even need code.

DougBrowning_0-1614263321003.png

 

Hope that helps

GarethBaker1

@DougBrowning I was trying to be efficient by only pulling back the fields that I needed but have changed it to return all fields and my expressions are now working in Field Maps 😀

Thanks for sharing the info about the bug - hopefully can get fixed soon.

DougBrowning

Yep I did the same thing to reduce the size of the call since I'm calling so many.  One thing that helped is adding the geometry false as you can see in my statement.

My pop-up is now rather slow when online but offline it's super fast and we're normally offline so it's okay.

I just reported the error in the last month but it was directly to the team.  Hopefully not too long.

Glad I could help.

ChrisDunn1

Hi @DougBrowning - are you seeing the bug on both iOS and Android? I am able to reproduce it on iOS but not on Android so I wanted to verify that is what you're seeing as well.

Chris

DougBrowning

I am seeing the same issue on both Android and iOS.  For my lat pull over all I get is 0 on both.

thanks