Help: Pop-up with custom expression reports nothing but expression test gives result

64
3
03-16-2020 11:24 AM
Highlighted
New Contributor III

I'm working with a custom arcade expression to show multiple layers in a single pop-up. However, I've run into a snag that is only showing up with one of the hosted feature layers I'm working with (the exact same code, with different fields, works in the other hosted layer). The code is simple and provided below

var featSet = FeatureSetByName($datastore,"CommercialSaleRep", ['Name','PhoneNumber']);
var featI = Intersects(featSet, $feature);
for (var f in featI){
    Console(f.PhoneNumber)
    return f.PhoneNumber
}

When I test the expression, it provides the expected result. However, in the pop-up there is nothing.#

I've tried clearing the pop-up of everything but the expression and using a Display: A list of field attributes and none of those results in a working expression.

Do visibility ranges have any impact on what data can be drawn upon with a popup expression?
What else can I try checking?#

Reply
0 Kudos
3 Replies
Highlighted
Esri Esteemed Contributor

Hi Robert Domiano ,

There can be a number of reasons for this behavior, although what you describe is a bit strange. Could you try the following:

var featSet = FeatureSetByName($datastore,"CommercialSaleRep", ['PhoneNumber'], false);
var featI = Intersects(featSet, $feature);
var cnt = Count(featI);
if (cnt > 0) {
return First(featI).PhoneNumber;
} else {
return "No Phone Number available"
}

What I changed is:

  • I excluded the name field since it is not used afterwards (line 1)
  • I exclude the geometry to reduce traffic (line 1)
  • The count will validate how many intersecting polygons are found (line 3)
  • if the count is larger than 0, it will retrieve the value of the field PhoneNumber of the first polygon (this is simular a doing a loop and return inside the loop)
  • If there are no intersections the text "No Phone Number available" will be returned

The zoom level influences the precisión of the geometry. Try zooming in until you see an intersection between the features and see if the result changes when you click on the feature.

Reply
0 Kudos
Highlighted
New Contributor III

This is much more efficient than what I was working with, thank you! I found that the issue was with using a list of field names rather than just a single field. I'm not sure why, but assume it was with how I asked for a return/looped through it.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Robert Domiano ,

There shouldn't be any problem with requesting multiple field and looping through it. If you look at this post https://community.esri.com/docs/DOC-12773-using-featuresetby-functions-in-arcade-to-drill-down-to-ot... and scroll down to the second expression, you will see that I loop through a feature set and extract two values. Maybe it is because I didn't restrict the fields (I simply request all of them which is not a good thing to do for performance reasons) but I am pretty sure this would work in case I only would have specified the two field I am using. Are you sure that the names of the fields are correct and you are not using the alias? 

Reply
0 Kudos