Select to view content in your preferred language

Arcade "Expects"

171
2
Jump to solution
a week ago
NAOMIPAUL
Occasional Contributor

I am having issue with using an Arcade expression for a Pop-up. The end goal is to only show a list of Field Name Alias that are equal to "Yes" for a select set of fields (not all the fields). 

Expects($feature, "ADA", "Amphitheater", "Baseball", "Basketball", "BattingCage", "Beach", "BoatRamp", "Boating", "Clubhouse", "CommunityCenter", "Concessions", "Cornhole", "DiscGolf", "DogPark", "Equestrian", "Fishing", "FitnessPavillion", "Football", "Fountain", "Garden", "Gazebo", "Golf", "Greenway", "GreenSpace", "Gym", "Horseshoe", "Kitchen", "Lake", "LittleLeague", "Paddle", "PaddleCraft", "PicnicArea", "PicnicPad", "PicnicTables", "Pickleball", "Pier", "PingPong", "Pool", "PumpTrack", "RecreationCenter", "Restrooms", "Shelters", "Skateboard", "Soccer", "Softball", "SplashPad", "Swim", "Tennis", "Track", "Trails", "Volleyball", "Walkway")
var sch = Schema($feature)
var Yes =[]
for(var field in $feature){
    if($feature[field] == "Yes"){
        for(var s in sch.fields){
          if(sch.fields[s].name == field){
            Push(Yes, sch.fields[s].alias);
            break;
          }
        }
    }    
}
return Concatenate(Yes, "\n") + TextFormatting.NewLine + $feature.Other
 
The issue I am having is that the result shows "Parking", even though Parking is not in the list of Field Names. 
 
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Expects is more critical when the Arcade expression is used in Visualization and Labeling. From the documentation:

In some profiles, such as Visualization and Labeling, apps only request the data attributes required for rendering each feature or label.

You're getting the list of fields from the feature, which will contain all fields in the Popup profile. You can put some logic in there to skip fields you don't want to include

for(var field in $feature){
  if (field != 'Parking'){
    if($feature[field] == "Yes"){
      for(var s in sch.fields){
        if(sch.fields[s].name == field){
          Push(Yes, sch.fields[s].alias);
          break;
        }
      }
    }
  }    
}

 

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

Expects is more critical when the Arcade expression is used in Visualization and Labeling. From the documentation:

In some profiles, such as Visualization and Labeling, apps only request the data attributes required for rendering each feature or label.

You're getting the list of fields from the feature, which will contain all fields in the Popup profile. You can put some logic in there to skip fields you don't want to include

for(var field in $feature){
  if (field != 'Parking'){
    if($feature[field] == "Yes"){
      for(var s in sch.fields){
        if(sch.fields[s].name == field){
          Push(Yes, sch.fields[s].alias);
          break;
        }
      }
    }
  }    
}

 

0 Kudos
NAOMIPAUL
Occasional Contributor

Thank-you, that worked perfectly!

0 Kudos