Select to view content in your preferred language

Arcade popup expression works in test doesn't work in popup

505
1
Jump to solution
11-15-2023 11:02 AM
ElisabethFenn
Occasional Contributor

I am trying to create popups in map viewer that show different fields depending on the activity type of the polygon. I've written this expression (see below) and when I run it in the expression editor it works perfectly. When I look at my popup, I get all of the correct field names, but only some of the data. Any idea what I'm missing here? Photos attached of what I see in the test space vs the popup. 

Thanks!

//create feature set from Activities layer
var fs = FeatureSetByName($map, 'Activities')

//define categories of activity types
var harvest = ['Clearcut','Overstory Removal','Improvement Thinning','Cluster Thinning','Free Thinning','Thinning From Above (Release Cut)','Crown Thinning','Crop Tree Release','Early Commercial Thinning','Group Shelterwood','Two-Stage Shelterwood','Three-Stage Shelterwood','Irregular Shelterwood','Deferred or Low Density Shelterwood','Shelterwood w/Reserves or Retention','Patch Cuts or Progressive Clearcuts','Seed Tree','Strip Cuts','Group Selection','Individual Tree Selection','Combined Group & Individual Tree Sel','Salvage Harvest','Wildlife Habitat Improvement']
var sitePrep = ['Chemical Site Prep','Mechanical Site Prep']
var inventory = ['Cruise','Planting','Survival','Crown Closure','Carbon Cruise','Growth and Yield','Audit Cruise','EFI','Post Ops Cruise','Permanent Growth Plots','CFI','Regen','Maple Taps',]

//define fields to display for each category
var harvestfields = ['Type','Status','JOB_NAME','Activity_Manager','ForestryNotificationfNum','CERTIFICATION','EASEMENT','T_E_PRESENCE','Method','HU_STATUS','EstimatedStart','ActualStart','EstimatedStop','ActualEnd','Contractor','Subcontractor','ACRES','MGT_RESTRICTION','RESTRICTION_DSC','Budget','EstimatedGrossRevenue','ActualGrossRevenue','EstimatedNetRevenue','ActualNetRevenue','OPERABILITY','Season','MARKED','StandAge','SILV_SYS','Document_Link','NOTES','Township','County','State','LVI_CODE','CreatedBy','CreatedOn','ModifiedBy','ModifiedOn','SUPER_TYPE','CERT_NUMB','Prescriptions','POST_OP_STATUS','POST_OP_STRATA','POST_OP_OS_TYPE','POST_OP_US_TYPE','OS_SP_1','OS_SP_2','US_SP_1','US_SP_2','OvYrEstabR','UnYrEstabR','YR_COMPLETE']
var siteprepfields = ['Type','Status','JOB_NAME','Activity_Manager','CERTIFICATION','EASEMENT','T_E_PRESENCE','Method','EstimatedStart','ActualStart','EstimatedStop','ActualEnd','Contractor','Subcontractor','ACRES','MGT_RESTRICTION','RESTRICTION_DSC','Budget','TotalEstimatedCost','TotalActualCost','EstimatedLaborCost','ActualLaborCost','EstimatedMaterialsCost','ActualMaterialsCost','OPERABILITY','Season','PRE_COM_TREATMENT_1','PRE_COM_TREATMENT_2','PRE_COM_YR_1','PRE_COM_YR_2','StandAge','Document_Link','NOTES','Township','County','State','LVI_Code','CreatedBy','CreatedOn','ModifiedBy','ModifiedOn']
var inventoryfields = ['Type','Status','JOB_NAME','Activity_Manager','CERTIFICATION','EASEMENT','EstimatedStart','ActualStart','EstimatedStop','ActualEnd','Contractor','ACRES','Method','Budget','TotalEstimatedCost','TotalActualCost','EstimatedLaborCost','ActualLaborCost','EstimatedMaterialsCost','ActualMaterialsCost','Miscellaneous_Cost','Project_Source','Document_Link','NOTES','Township','County','State','LVI_Code','CreatedBy','CreatedOn','ModifiedBy','ModifiedOn']

//create popup
function createPopup (fieldsList) {
  var popup = ''
  for (var f in fieldslist){
    var field = fieldslist[f]
    var value = DomainName(fs, field, $feature[field])
    popup += field + ": " + value + TextFormatting.NewLine
  }
  return popup
}

//call createPopup function
if (Includes(harvest, DomainName($feature, 'Type'))) {
  createPopup(harvestfields)
} else if (Includes(sitePrep, DomainName($feature, 'Type'))) {
  createPopup(siteprepfields)
} else if (Includes(inventory, DomainName($feature, 'Type'))) {
  createPopup(inventoryfields)
} else {
  return "not found"
}

 

0 Kudos
1 Solution

Accepted Solutions
ElisabethFenn
Occasional Contributor

Resolved the issue. I needed to add this to the beginning of the expression: 

Expects($feature, '*')

 

This community post helped me get there.

View solution in original post

0 Kudos
1 Reply
ElisabethFenn
Occasional Contributor

Resolved the issue. I needed to add this to the beginning of the expression: 

Expects($feature, '*')

 

This community post helped me get there.

0 Kudos