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;
Solved! Go to Solution.
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
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
Did you use the code block in my post or did you alter it at all?
The only thing I changed was the fieldsToInclude variable and the map name. Everything else was the same.
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.
Yup, you called it! Aliases were not as expected, so it was a data issue. Thanks!