ARCED expression for PopUp

11-17-2021 06:26 AM
Labels (1)
New Contributor
I want to configure a Popup in a webmap in AGOL
I have data fields that define purposes in a particular area.
for Example: Purpose A field - if the purpose exists the field value will be- Purpose A, and so on I want only the fields that have a value to appear in the popup Purpose A-Butterfly Garden
Purpose B-Null
Purpose C-Null
Purpose D-Dog Garden
Purpose E-Null
the Wonted end result -
Butterfly Garden, Dog Garden

and not
Butterfly Garden, , , Dog Garden,
I was thinking of writing an expression in ARCED that would create the list How do I write in ARCED an expression that asks first if there is a value in the field before it plants the value in the POPUP to avoid empty spaces



0 Kudos
4 Replies
New Contributor III

If I understand correctly, it sounds like an simple if/else will get it done for you.

Happy to help iif you need assitance setting up the argument.

if ( IsEmpty($feature["OCC_ELUM"] )) {
return "A"
else  {
return "B"

0 Kudos
MVP Frequent Contributor

A simple if/else is not going to work here, because any number of purpose fields can have values. If you do a simple if/else chain like below, only the first purpose will be returned, completely ignoring possible other purposes.

if(!IsEmpty($feature.PurposeA)) {
  // if PurposeA is filled ("Butterfly Garden" in the example), the expression will end here.
  // Other purpose fields (PurposeD - "Dog Garden") will be ignored!
  return $feature.PurposeA
if(!IsEmpty($feature.PurposeB)) {
  return $feature.PurposeB
if(!IsEmpty($feature.PurposeC)) {
  return $feature.PurposeC
if(!IsEmpty($feature.PurposeD)) {
  return $feature.PurposeD

Have a great day!
0 Kudos
New Contributor III

Maybe I am misunderstanding, but the way I've done this in the past is to use nested arguements in the if expression.

EX. if(IsEmpty($feature.Field_A)) && (IsEmpty($feature.Field_B)) == false){

return $feature.Field_B

0 Kudos
MVP Frequent Contributor
// build an array of the purpose field values
var purposes = [
// use that to build an array of non-empty purpose values
var non_empty_purposes = []                  // empty array
for(var p in purposes) {                     // loop through purposes
  if(!IsEmpty(purposes[p])) {                // if purpose is not empty (null or "")
    Push(non_empty_purposes, purposes[p])    // append to array
// return the concatenated array as string
return Concatenate(non_empty_purposes, ", ")

Have a great day!