Hi, all. I'm still quite new to SuiteScript, mostl...
# suitescript
j
Hi, all. I'm still quite new to SuiteScript, mostly working with 2.x. I'm trying to alter an existing 1.0 script built by another developer and a little puzzled. I just need to check if the value in a field is one of 8 or 9 values and return true. I thought I could just put those values in an array and check if the field value was in that array, but I get an error.
if (myArray.includes(fieldValue)) {
But this returns an error. I guess includes() doesn't work in 1.0? Is putting together a long set of || clauses my best bet? Error I get: TypeError: Cannot find function includes in object 4633,4634,6928,6954.
a
1.0 doesn't support includes you can use the oldschool indexOf instead if a value is found it returns the index, if its not found it returns -1 so you could do
if (myArray.indexOf(fieldValue) >-1) {
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
e
SuiteScript 1.0 is ES5.1
2.x is ES2019 (I believe)
j
Ah, perfect. That'll do. Thanks so much. Certainly makes me appreciate 2.x even more.
b
2.1 is es2019, suitescript 2.0 is es5.1
😁 1
❤️ 1
2.x is ambiguous and can mean either depending on account settings
👍 1