I'm trying to write an expression for a pop up in ArcGIS Online that will display the name of the fields if there is a specific value under those fields for each feature. I adapted the following script that I found online.
var i = 0
var features = [];
function addvalue(feat) {
if (!IsEmpty(feat)) {
features[i++] = feat;
}
}
addvalue($feature.schoolCommGardenQuarter);
addvalue($feature.smarterLunchQUARTER);
addvalue($feature.schoolWellnessQuarter);
addvalue($feature.keysNAPSACCquarter);
addvalue($feature.healthConcessionsQuarter);
addvalue($feature.foodPantryBackpackQuarter);
addvalue($feature.farmMarketorPopUpQuarter);
addvalue($feature.rydQUARTER);
addvalue($feature.directEd);
addvalue($feature.onetimeRYDEventQuarter);
return Concatenate(features, ";")
This runs without issue but it returns the values as a concatenated list (such as [YES;NO;YES;YES]
). I want to edit the above script so that it returns a text string of the field names that have YES
as a value.
I have since edited my script so that the if statement evaluates for the 'yes' value. I still am having trouble figuring out how to access and return the field names rather than the 'yes' values.
var i = 0
var features = [];
function addvalue(feat) {
if (feat == 'Yes') {
features [i++] = feat;
}
}
addvalue($feature.schoolCommGardenQuarter);
addvalue($feature.smarterLunchQUARTER);
addvalue($feature.schoolWellnessQuarter);
addvalue($feature.keysNAPSACCquarter);
addvalue($feature.healthConcessionsQuarter);
addvalue($feature.foodPantryBackpackQuarter);
addvalue($feature.farmMarketorPopUpQuarter);
addvalue($feature.rydQUARTER);
addvalue($feature.directEd);
addvalue($feature.onetimeRYDEventQuarter);
return Concatenate(features, ";")