Arcade Pop-up Expression not Displaying All Fields and Attributes

252
2
02-19-2024 10:34 AM
Labels (3)
JasonSladinski1
New Contributor II

I have an Arcade Expression to not display any fields that have attributes that are null in the pop-up in the New Map Viewer.  When I test it, it shows the dictionary correctly.  I then configure the pop-up to use the expression in a Text element (I've also tried it as an Arcade element), and it will only display 3 attributes (GlobalID, OBJECTID, and WBS_Number).  If I turn the pop-ups off and then back on again, it'll show all of the attributes without any nulls like it's supposed to, but if I click on a feature, it displays only 3 fields.  I've tried everything I can think of, so any help or insight is appreciated.

Arcade Expression with test:

// Get all the field names
var fieldNames = Schema($feature).fields;

// Initialize an empty dictionary to store non-null attributes
var nonNullAttributes = {};

// Iterate over each field
for (var i in fieldNames) {
    var fieldName = fieldNames[i].name;
    var fieldValue = $feature[fieldName];

    // If the field value is not null, add it to the nonNullAttributes dictionary
    if (!IsEmpty(fieldValue)) {
        nonNullAttributes[fieldName] = fieldValue;
    }
}

// Return the non-null attributes
return nonNullAttributes;

 

JasonSladinski1_1-1708367265071.png

Pop-up Configuration:

JasonSladinski1_0-1708367456255.png

Simple Text Element configuration with just the expression:

JasonSladinski1_1-1708367495490.png

 

 

Correct Pop-up when first opened or after turning pop-ups off and on:

JasonSladinski1_0-1708367242022.png

Incorrect pop-up after clicking on features:

JasonSladinski1_2-1708367610297.png

 

0 Kudos
2 Replies
JohnEvans6
New Contributor III

You'd need to post all your code if you can, but at a glance your output shouldn't be a dictionary I don't think. What is your return statement?

0 Kudos
JasonSladinski1
New Contributor II

Sorry, I thought I had the full code in the image, but Here is the code:

// Get all the field names
var fieldNames = Schema($feature).fields;

// Initialize an empty dictionary to store non-null attributes
var nonNullAttributes = {};

// Iterate over each field
for (var i in fieldNames) {
    var fieldName = fieldNames[i].name;
    var fieldValue = $feature[fieldName];

    // If the field value is not null, add it to the nonNullAttributes dictionary
    if (!IsEmpty(fieldValue)) {
        nonNullAttributes[fieldName] = fieldValue;
    }
}

// Return the non-null attributes
return nonNullAttributes;
0 Kudos