Check if variable matches one of strings in array

269
2
Jump to solution
02-26-2024 08:15 PM
TTtttTeee
New Contributor III

Hello, I am just trying to prepare attribute rule to check if $feature.field matches one of strings in an array, and then, if yes, another field is going to be populated with specific attribute value.

I have tried the code below but unfortunately it returned an error, saying "Close Parenthesis expected in line 2"

Much appreciated if anyone point out any cause of the problem or give me a solution.

var array1 = ["Lake", "Mountain", "River"]
if (array1.includes($feature.FeatureType)) {
    return {
        result: {
            attributes: {
                ThemeType: "Nature"
            }
        }
    }
}

 

Tags (2)
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor
In arcade, there are no function on arrays. You need to call

Includes(inputArray, value)

View solution in original post

2 Replies
MikeMillerGIS
Esri Frequent Contributor
In arcade, there are no function on arrays. You need to call

Includes(inputArray, value)
TTtttTeee
New Contributor III

Thanks a lot MikeMillerGIS!

It works fine now.

0 Kudos