OL Learn

Workflow Does Not Support Javascript Method Includes


Title says it all. Oversight perhaps? Why is “Includes” available in the designer but not in Workflow?

Error I get in Workflow is:

W3602: Error 0 on line 5, column 1: Microsoft JScript runtime error: Object doesnt support this property or method.



Workflow doesn’t use the same engine as the Designer. The Includes method is part of ECMASCRIPT 6 and is therefore not yet implemented in all JS engines.

In a Workflow script, you can add the method yourself to the String prototype by adding the following line at the top of your script:

String.prototype.includes = function(strToTest) {
  return this.indexOf(strToTest)>=0;

Once you’ve done this, you can use the method as you would in Designer (e.g.if (myString.includes("ZZZ") {...}).

Thanks Phil, that made life easier.


I’ve just tried putting this in a workflow script and just get the error:

W3602 : Error 0 on line 2, column 37: Microsoft JScript compilation error: Syntax error

Any ideas?



I just corrected the typo in the code above so you can now copy and paste it.

However, please note that this workaround is no longer required as the includes() method is now natively available when you select the Enhanced JScript option as your scripting language. You can set that language (and you should!) as the default one in Preferences | Behavior | Default Configuration.

Thanks Phil

Is this new function only available in the latest version of workflow? we are only using V2018.1.1.1


Your version is old, you should really consider updating to the current version.
As for the Enhanced JScript language option, it was introduced in the 2019.2 release.

So until you update to a more recent version, you’ll have to use the corrected polyfill above.

Yeah I have been saying we need to upgrade, hopefully will get it done soon