FeatureSetBy Arcade Functions Supported in Field Maps App?

1802
9
Jump to solution
01-04-2022 12:54 PM
danbecker
Occasional Contributor III

Enterprise 10.9, Map Viewer BETA. Created a popup expression using the FeatureSetByRelationshipName function. I can successfully retrieve the parent feature attribute in the popup, no issues.

But, when the webmap is accessed with the Field Maps app (Android) the popup shows an Error Code 6, Illegal State. Invalid relationship name.

Question of the day: Are any of the FeatureSetBy.. Arcade functions supported in the latest field maps app? If so, does the map have to be online, ad-hoc created offline, or pre-defined offline?

 

thanks.

0 Kudos
1 Solution

Accepted Solutions
danbecker
Occasional Contributor III

Here's the solution, scrap the Arcade Filter() function, it simply does not work with globalid while offline.

This expression works fine both online/offline. Upper/Lower case globalid wasn't the issue, both FM and map viewer BETA in Enterprise 10.9 were displaying Upper case. But, just for safety I used Lower.

var relate_guid = $feature["rel_guid_pcs"];
var featSet = FeatureSetByName($map,"Point Count Stations", ['pcs_id','globalid'], false);
for(var feat in featSet){
    if(Lower(feat.globalid)==Lower(relate_guid)){
        return feat.pcs_id;
    }
}

 

View solution in original post

9 Replies
DougBrowning
MVP Esteemed Contributor

Yep it works now I kept bugging for it.  Offline works also as long as the parent and child are both in the offline replica.

I had seen some have trouble using relationship class name.  I always use the layer name from the map and filter based on my key like this.  Works great.

var sql = "PointID = '" + $feature.PointID + "'";
var tbl = Filter(FeatureSetByName($map,"Points", ['Use * or a list of fields here'], false), sql);
return First(tbl).DesignLat

My guess on relationship name is it has a longer name somehow like service.rcname or something but not sure.

Hope that helps.

0 Kudos
danbecker
Occasional Contributor III

I cannot get it to work offline, see below details.

 

Environment: Enterprise 10.9 with PostgreSQL published feature service.

Using map viewer BETA released with 10.9, added both point feature classes, they are related via globalid-guid.

Arcade Expression on child layer:

var relate_guid = $feature["rel_guid_pcs"];
var featSet = Filter(FeatureSetByName($map,"Point Count Stations", ['pcs_id','globalid'], false), 'globalid = @relate_guid');
return First(featSet).pcs_id;

Online result:

both map viewer BETA and Field Maps app (Android) work great. Select a child point and above expression retrieves parent.pcs_id.

Offline result:

same webmap, download ad-hoc offline area in Field Maps app (Android). Select a child point and it displays -- which obliviously doesn't work.

Field Maps app (Android) error:

Expression Name: expr0

Expression Title: Arcade

Error Domain: com.esri.arcgisruntime.ArcGISRuntimeException

Error Code: 15

Error Description: Invalid call.

Unable to evaluate arcade expression. Evaluation_error_code::unexpected_null_value Line :3

@DougBrowning 

1) Are you using AGOL or Enterprise?

2) Hosted feature service or published feature service?

0 Kudos
danbecker
Occasional Contributor III

But, this edited Arcade Expression does work offline!

 

var relate_guid = $feature["rel_guid_pcs"];
var featSet = Filter(FeatureSetByName($map,"Point Count Stations", ['pcs_id','globalid','objectid'], false), 'objectid > 0');
return First(featSet).pcs_id;

 

What changed?

I'm guessing that the offline replica.geodatabase that gets created either:

  1. Doesn't preserve globalid. So the Filter expression: parent.globalid = child.relate_guid doesn't retrieve anything. (I find this hard to believe). I tried adding a new related child point WHILE OFFLINE and the orig. Arcade expression still doesn't work.
  2. the Filter() data fcn doesn't support SQL queries against globalid while offline. (more plausible).

 

ESRI -- Any docs on this?

0 Kudos
DougBrowning
MVP Esteemed Contributor

Well  map viewer BETA does not support relationships classes yet.  No button for it at all so that is prob not going to work out.

Next I wonder of you are finding the lower vs upper case globalID problem.  Field Maps is doing lower while AGOL is upper and it is causing me pains.  See here  https://community.esri.com/t5/arcgis-field-maps-questions/field-maps-is-creating-lowercase-globalid-...

Above it looks like you are not using the filter right.  You need to filter by global.  See my example.

0 Kudos
danbecker
Occasional Contributor III

Online, both app and Map Viewer BETA both of these filter expressions work, offline in app, neither of them work.

"globalid = '" + relate_guid +"'"

"globalid = @relate_guid"

 

Online/Offine, this filter expression works:

'objectid > 0'

 

@DougBrowning, can you try a filter expression in your environment that uses globalid? It would be great if you could repo this.

0 Kudos
DougBrowning
MVP Esteemed Contributor

have you tried GlobalID  maybe it is a case issue?     A filter of objectid > 0 is just going to give you everything in the DB and not do a lookup.

0 Kudos
DougBrowning
MVP Esteemed Contributor

also maybe the extra quotes are missing i would try.  Not sure on your field names here but

var sql = "rel_guid_pcs = '" + $feature.GlobalID + "'";

0 Kudos
danbecker
Occasional Contributor III

I tried all of those suggestions, see above. Field names in my case are always lower case, since the backend is PostgreSQL.

Realize objectid > 0 would return everything, I was just trying to determine if the problem was Filter() or FeatureSetByName(). See below, problem was Filter().

0 Kudos
danbecker
Occasional Contributor III

Here's the solution, scrap the Arcade Filter() function, it simply does not work with globalid while offline.

This expression works fine both online/offline. Upper/Lower case globalid wasn't the issue, both FM and map viewer BETA in Enterprise 10.9 were displaying Upper case. But, just for safety I used Lower.

var relate_guid = $feature["rel_guid_pcs"];
var featSet = FeatureSetByName($map,"Point Count Stations", ['pcs_id','globalid'], false);
for(var feat in featSet){
    if(Lower(feat.globalid)==Lower(relate_guid)){
        return feat.pcs_id;
    }
}