Select to view content in your preferred language

Arcade not displaying in popup

414
1
Jump to solution
08-02-2022 11:10 AM
Labels (1)
SpatialSean
New Contributor III

I have two expressions that are essentially the same and both are functional when testing them but when loading them into the popup only exp0 loads.

Here is the expression, less the ID.  The console expression does work and loads the correct number.  You'll see from the picture the line is there for the popup but nothing is displaying.

 

// Create a 2 mile buffer around the selected event
var buff = BufferGeodetic($feature, 2, 'miles')

// Return Retail Stores within 2 miles of what's selected
var portal = Portal("https://www.arcgis.com")
var nrstoreLocations = FeatureSetByPortalItem(portal,"REMOVED_ID", 0, ['Asset_Type'])
var nearbyNRStores = Intersects(nrstoreLocations, buff)

var nrStores = []

//console(count(nrstoreLocations))


for(var f in nearbyNRStores){
    var distance = DistanceGeodetic(f, $feature, "miles")
    var nrstore_distance = Dictionary("NRStoreName",f.Asset_Type,"Distance",distance)
    nrStores[Count(rSTores)] = nrstore_distance 

}

//console(count(rStores))

function compareDistance(a,b){
  if(a['Distance']<b['Distance'])
    return -1;
  if(a['Distance']>b['Distance'])
    return 1;
  return 0;
}

// Build the pop-up string
var popup = ''
nrStores = Sort(nrStores, compareDistance)
for(var nrStore in nrStores){
    popup += nrStores[nrStore].NRStoreName + ": " + ROUND(nrStores[nrStore].Distance, 1) + "mi" +
        TextFormatting.NewLine
}

//return pop-up string
When(Count(nrStores) == 0, TextFormatting.NewLine + TextFormatting.NewLine +
        "No NonRetail within 2 miles of event",

    Count(nrStores) == 1, TextFormatting.NewLine + TextFormatting.NewLine +
        "1 NonRetail within 2 miles of event" + TextFormatting.NewLine
        + popup,
    
    TextFormatting.NewLine + TextFormatting.NewLine +
        Count(nrStores) + " NonRetail within 2 miles of event" + TextFormatting.NewLine
        + popup)

 

 

SpatialSean_2-1659463732053.png

 

SpatialSean_1-1659463666717.png

 

 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

In lines 17 and 21, you're using rStores instead of nrStores, that might be it...


Have a great day!
Johannes

View solution in original post

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

In lines 17 and 21, you're using rStores instead of nrStores, that might be it...


Have a great day!
Johannes
0 Kudos