I want to symbolize points based on the presence of specific words in a variety of fields. There are 19 fields that hold priority values of either 'High', 'Medium', 'Low', or null. Ideally, what I would like is this:
If any of the fields have a value of 'High', then the symbol category will be 'High' regardless of the number of 'High' values, or whether or not any of the 19 fields have values of 'Medium' or 'Low'
If none of the fields are 'High', then move on to do the same thing for medium, then to low.
My idea was to create an array of the fields, then do a for loop to check for the priority words in the fields. If the word appeared in any of the array fields, then a variable will change from 0 to 1. Then I can do a cascading If statement to get my final categorization. I think my big issue is the for loop, as usual.
// initilize variables for different priority values
var hCount = 0
var mCount = 0
var lCount = 0
// priority fields
var p1 = $feature.Priority_1
var p2 = $feature.Priority_2
var p3 = $feature.Priority_3
var p4 = $feature.Priority_4
var p5 = $feature.Priority_5
var p6 = $feature.Priority_6
var p7 = $feature.Priority_7
var p8 = $feature.Priority_8
var p9 = $feature.Priority_9
var p10 = $feature.Priority_10
var p11 = $feature.Priority_11
var p12 = $feature.Priority_12
var p13 = $feature.Priority_13
var p14 = $feature.Priority_14
var p15 = $feature.Priority_15
var p16 = $feature.Priority_16
var p17 = $feature.Priority_17
var p18 = $feature.Priority_18
var p19 = $feature.Priority_19
// set up array for loop
var priorityFields = [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19]
// Check for the word 'High' as the value in any of the priorityFields
// This is where I am lost
for (var p in priorityFields){
if (p=='High'){ hCount = 1}
else {hCount}
}
// Then do the same thing for 'Medium' and 'Low'
// Finally, compare Count variables. If hCount is above 0, then 'High', if hCount is 0, then check the same for mCXount, etc. I can write this code later. then if all of the Count variables are 0, the final category is something like 'No Maintenance Needed'.