Web AppBuilder - Attribute Expressions

713
2
02-13-2020 12:04 PM
StephenPalka
New Contributor II

Hi all. I'm having some issues with a web map and web app that I am building through my organization's ArcGIS Online portal.

I have a web map with multiple layers and I have configured some of the popups for different layers with attribute expressions. The code I'm using looks like this:

// Convert Lines/Polygons to Points
var PointGeometry = Centroid(Geometry($feature));
var pointX = PointGeometry.x;
var pointY = PointGeometry.y;

return (text(pointX) + ":" + text(pointY);‍‍‍‍‍‍‍‍‍‍‍‍

The popup works fine but when I try to view the attribute table for this layer in the web app no records ever load. In Chrome's console I am getting the error "Error: Runtime Error: Cannot call member method on null."

Changing the code to:

// Convert Lines/Polygons to Points
var PointGeometry = Centroid(Geometry($feature));

return (text(PointGeometry));‍‍‍‍

actually resolves the issue. Obviously this is not ideal since it is much harder for users to read. It seems like accessing the attributes of the geometry is causing the issue.

Any ideas why this is happening?

0 Kudos
2 Replies
UriGilad_EsriAu
Esri Contributor

HI Stephen, 

I've tried to replicate your error but on my end everything worked fine:

The issue might be in your layer. Did you try other layers? If it's possible please share your layer and I can test it on my end.

If your first code fails and the second succeeds, there might be a problem with passing the PointGeometry.y/x. Try this:

var PointGeometry = Centroid(Geometry($feature));
var pointX = text(PointGeometry.x);
var pointY = text(PointGeometry.y);
return (pointX +': '+ pointY);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.

0 Kudos
StephenPalka
New Contributor II

Hey, thanks for the reply. I tried your code on multiple layers (both point and polyline) and am still having issues. It's hard to pin down what is happening but all of the issues I'm having deal with the attribute table widget.

Before, with my code, no records would pop up in the attribute table and I would get the error immediately when clicking on the option in the popup to view the record in the attribute table. 

With your code, I can now view the records in the attribute table but I am getting the same error when I try to export the feature to a CSV. Not sure why this would change the point at which the error pops up.

Unfortunately, I can't share the layers I am using with you as they are behind my organization's firewall.

0 Kudos