Error This pop-up cannot be saved to the layer because it contains one or more attribute expressions (Arcade) that use $map.

435
3
08-11-2020 08:20 AM
RobertLiveanu
New Contributor II

Hello,

I'm getting an error message when saving a layer in my web map in ArcGIS Online. It comes after I set up an attribute expression to put into my pop-up. The expression works, the code works, the values in the pop-up are correct, but apparently having a reference to $map in the code leads to this attribute expression not being saved into the layer (all other edits to the layer - adding features, modifying attributes, etc., are still saved; it's the attribute expression itself that won't save).

I based my code off of this help page: https://www.arcgis.com/apps/Cascade/index.html?appid=1c225c84ba234487b7e9a9180465fd58 

For reference, what I was doing with my code was: I have two layers that are related (through the field in both layers called "Project"), a polygon layer and a point layer. The point layer has a field for quantity ("Quant"). For each polygon, I want the sum of the quantities of all the points that are within/related to that polygon, and for that sum to appear as a separate field in the polygon pop-up. 

Ex: Polygon A contains 3 points, each with a Quant of 4. Therefore, Quant_total = 12.

Like I said, the code works, the pop-up looks great, but because of the $map, the attribute expression won't save. I'm not well-versed enough in coding or expressions to figure it out, I simply copied the code from the helpful link above. So, what can I do? Thanks!

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

Hi af2r_carto1 ,

The error message is kind of weird and may not represent what the error is really about. In case the layers are part of the same feature service you could use $datastore in stead of $map, but I think something else is going on. 

Would it be possible to share the map and data? You can create a group, share the map and data with that group and invite me to that group using my AGOL username "xbakker.spx".

0 Kudos
RobertLiveanu
New Contributor II

Hi Xander Bakker - I waited a couple days before replying because AGOL was doing weird things for a bit. I logged into my account the other morning to find that the attribute expression causing the error message was saved from one day to the next, while the other expressions I had made without the error message, were not saved, including some other configure attribute actions I had taken. However, everything has been acting well for the last couple of days. I changed $map to $datastore as you suggested, and the error did not appear anymore. The original expression causing the error and all other expressions and all other attribute configurations in both my layers of my map are saved and good.

Did you still want me to share my map and data for you to explore the original error message?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Robert Liveanu ,

If everything is working now, I would not know how to investigate the reason for this error. However, if you want me to look at the expression in more detail, you can share the map and data as mentioned before and I will have a look. 

0 Kudos