Select to view content in your preferred language

AGOL Update - Pop-up fields with Arcade expression no longer displaying

223
4
Jump to solution
2 weeks ago
Espressoz
New Contributor

Hi all,

I have a simple map where the main point data are pulled from a live/referenced CSV published via Google Sheets. I used an Arcade expression (through the "Add Content > Arcade" block) to prevent any fields with null/empty string records from displaying in the pop-ups (styled as just the default attribute table). Until the update, it was working perfectly.

After the update yesterday, the correctly configured table will initially display for a single point, but when I click on other features (or back to that original point), where the table should be in the pop-up is completely blank. I can reliably reproduce this when I toggle "Enable pop-ups."

When I test run the code, the correct output appears. I'm definitely a beginner with Arcade and got the code below from another user, modifying it for my map. I've already tried quite a few workarounds, but nothing is producing what I had before -- it's just blank. The Text block that precedes the Arcade expression still displays normally.

Is this an update bug, or should I be doing something different? I would appreciate any help. Let me know if I can provide further details. Thank you!

Here is the code that previously worked for me:

var attributes = Dictionary($feature)["attributes"];
var fieldInfos = [];
var attributeValues = {};

var excludeFields = ["Field1", "Field2", "Field3"]; //Excluded fields, null or not null

var layer_schema = Schema($feature);
var fieldAliases = {};

for (var i = 0; i < Count(layer_schema.fields); i++) {
    var field = layer_schema.fields[i];
    fieldAliases[field.name] = field.alias;
}

for (var key in attributes) {
    var value = attributes[key];

    if (!IsEmpty(value) && value != "" && IndexOf(excludeFields, key) == -1) {
        var displayName = key; // Default to field name
        
        // Use alias if available
        if (HasKey(fieldAliases, key)) {
            displayName = fieldAliases[key];
        }
        
        Push(fieldInfos, { fieldName: key, label: displayName });
        attributeValues[key] = value;
    }
}


return {
    type: 'fields',
    fieldInfos: fieldInfos,
    attributes: attributeValues
};

 

 

0 Kudos
2 Solutions

Accepted Solutions
timcneil
Esri Contributor

Hi @Espressoz ,  

Sorry to hear you're having difficulties. It's hard to say what may be occurring without looking at the dataset/map... but have you tried using the Expects() function at the beginning of your script?

The mention you make of the initial popup displaying OK when you toggle "Enable pop-ups" leads me to believe this may help with the issue. 

Taylor

View solution in original post

Espressoz
New Contributor

Hi @timcneil,

Yes, that worked! That was a simple solution after my many failed attempts. Thank you so much for your help!

I'm not sure if this was the best way to use the function, but if anyone is having a similar issue, I just used the below at the very beginning:

Expects($feature, "*")
 

Thank you again, Taylor!

View solution in original post

4 Replies
timcneil
Esri Contributor

Hi @Espressoz ,  

Sorry to hear you're having difficulties. It's hard to say what may be occurring without looking at the dataset/map... but have you tried using the Expects() function at the beginning of your script?

The mention you make of the initial popup displaying OK when you toggle "Enable pop-ups" leads me to believe this may help with the issue. 

Taylor

Espressoz
New Contributor

Hi @timcneil,

Yes, that worked! That was a simple solution after my many failed attempts. Thank you so much for your help!

I'm not sure if this was the best way to use the function, but if anyone is having a similar issue, I just used the below at the very beginning:

Expects($feature, "*")
 

Thank you again, Taylor!

StuartMoore
Frequent Contributor

i'm having similar issues and the Expects($feature, '*') didnt work unfortunately

0 Kudos
timcneil
Esri Contributor

Hi @StuartMoore , 

I looked briefly at your latest post. It looks like you may have been using an undocumented behaviour, but it's difficult to say for sure.

This comment may be helpful: https://community.esri.com/t5/arcgis-online-questions/change-in-arcade-return-of-array-after-latest-...