Select to view content in your preferred language

Map Viewer Pop-ups Aliases (Arcade)

783
5
Jump to solution
08-16-2023 06:39 AM
moremeowbell
New Contributor III

I am searching for a way to access the "alias" property of fields in Map Viewer pop-ups using Arcade. The following code only returns partial aliases, and looks like it's somehow mixing in field names with their aliases. Any suggestions on how to access the "alias" property in a way that is consistant?

var fieldsToInclude = ["tvd_ft_0",
                "well_status_type",
                "Symbology",
                "tvd_ft_bin_count"
                ];
var features = FeatureSetByName($map, 'Well Status-20K Grid', fieldsToInclude, false);
var aDict = Schema(features);
var aArray = aDict["fields"];
var output;

for (var i in $feature){
    if (!IsEmpty($feature[i]) &&
       ($feature[i] != 0)) {
        for(var j in aArray) {
            var dict = aArray[j];
            if (dict['name'] == i){
                output += dict['alias'] + ": " + $feature[i] + TextFormatting.NewLine + TextFormatting.NewLine;
            };
        };
    };
};
return output;
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

That code is working properly with a dataset I test it with. What are the results that you're getting? And do you have aliases set up properly for your fields?

var fieldsToInclude = ["FIELD_ID",
                "LAT",
                "LONG",
                "DEPTH_M"
                ];
var features = FeatureSetByName($map, 'Test', fieldsToInclude, false);
//the rest of the code was the same

test_fields.png

test_popup.png

 

View solution in original post

5 Replies
KenBuja
MVP Esteemed Contributor

That code is working properly with a dataset I test it with. What are the results that you're getting? And do you have aliases set up properly for your fields?

var fieldsToInclude = ["FIELD_ID",
                "LAT",
                "LONG",
                "DEPTH_M"
                ];
var features = FeatureSetByName($map, 'Test', fieldsToInclude, false);
//the rest of the code was the same

test_fields.png

test_popup.png

 

moremeowbell
New Contributor III

Did you use the code block in my post or did you alter it at all?

0 Kudos
KenBuja
MVP Esteemed Contributor

The only thing I changed was the fieldsToInclude variable and the map name. Everything else was the same.

0 Kudos
moremeowbell
New Contributor III

Okay awesome. Also, did the values returned for each field look right?

I’ll build a test layer from scratch to test. I didn’t build the layer that is being tested, so maybe something weird is going on with it. 

0 Kudos
moremeowbell
New Contributor III

Yup, you called it! Aliases were not as expected, so it was a data issue. Thanks!

0 Kudos