Arcade pop-up expression is working in Field Maps but not in Collector

639
1
03-22-2022 08:45 AM
BRENNEJM
New Contributor III

I have the arcade pop-up expression written (see below). The pop-up displays correctly in ArcGIS Online and in Field Maps. However, Collector returns a dash ("-"). I've reviewed a number of tutorials and Esri Community posts, but none seem to apply here. 

Expression 1

 

//Access 'Hydrant Inspections' table as a FeaureSet
var inspections = (FeatureSetByName($datastore,"Inspections"))

//Filter related features by using a common attribute
var UID = $feature.UID
var filterStatement = 'UID = @UID'

//Related features as a variable
var relatedData = Filter(inspections, filterStatement)

//Sort related features from oldest to newest
var relatedDataSorted = OrderBy(relatedData, 'InspectionDate ASC')

//Build the pop-up string by iterating through all related features
var popupString = ''
for (var f in relatedDataSorted){
    
    popupString +=
    
    Text(f.InspectionDate, 'MMMM D, Y') 
    + TextFormatting.NewLine +
    
    'Box Condition: ' +
    f.Condition + TextFormatting.NewLine +
    
    'Notes: ' +
    f.Notes + TextFormatting.NewLine +
    TextFormatting.NewLine
}

return popupString

 

 

I've also tried simpler expressions and get the same result. The bellow expression works in AGO and Field Maps, but not in Collector.

Expression 2

 

//Related features as a variable
var relatedData = FeatureSetByName($map,"Inspections")

var popupString = ''

//Add all inspection dates to a pop-up string
for (var row in relatedData){
    if ($feature.UID == row.UID) {
        popupString += Text(row.InspectionDate, 'MMMM D, Y')
    }
}

return popupString

 

EDIT

Some additional info. The above was all edited in the new Map Viewer. I tried authoring a new map in Map Viewer Classic and copied both of the above expressions. Expression 1 works in AGO and Field Maps, but not in Collector. However, Expression 2 only works in Field Maps. AGO returns a blank (" ") and Collector returns a dash ("-").

 

1 Reply
Felicitychun
New Contributor III

I have also found a similar issue where my arcade expression works in the Web map and Field Maps but not in Collector. All the expressions are used in the popups. This is my expression.

var InspAreas = FeatureSetByName($map,"Inspection Areas",["priority"])

First(Intersects(InspAreas, $feature)).priority

 However, I have other arcade expressions that work fine in Collector and have been relying on it for a long time which gets the geometry information of itself:

function MToLatLon(x, y) { //EPSG3857 to WGS84
    var originShift = 2.0 * PI * 6378137.0 / 2.0;
    var lon = (x / originShift) * 180.0;
    var lat = (y / originShift) * 180.0;
    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return [lat, lon];
    }
    
var geom = Geometry($feature);
var firstpart = geom.rings[0];
var outparts = [];
var counter = 0;
for (var pt in firstpart){
    //convert x y to lat lon\n    
    var latlon = MToLatLon(firstpart[pt].x,firstpart[pt].y)
    var ptstr = Concatenate(latlon[0], " ", latlon[1]);
    outparts[counter]= ptstr;
    counter = counter + 1;   
    }
    
return Concatenate(outparts, ";")

 Is there an issue in Collector interacting with other layers in the map through arcade expressions?

0 Kudos