Javascript command does not work in executeScript_Sandbox

This is because executeScript**_Sandbox** does not support the ES6 javascript command “.includes”. => The solution is to use .indexof instead of .includes.

So this version with .indexOf works in the sandbox:

{
  "Name": "include string test",
  "CreationDate": "2022-10-10",
  "Commands": [
    {
      "Command": "store",
      "Target": "test tim meyer",
      "Value": "e",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "if (${e}.indexOf (\"tim\") > -1)\n{\nreturn \"YES, it contains this string\";\n}\nelse\n{\nreturn \"NO, it does not contains this string\";\n}\n",
      "Value": "Result",
      "Description": "The ES5 alternative to .includes is .indexOf"
    },
    {
      "Command": "echo",
      "Target": "${Result}",
      "Value": "blue",
      "Description": ""
    }
  ]
}
1 Like