Whenever I attempt to use the '.includes()' method on string in ThingWorx composer, I always get an error saying that the .includes method can not be found on the object. I even log the type of the variable that I am trying to edit, just to make sure it is in fact a string. And I still can not get around this.
Here's an example of what I'm talking about:
var myString = 'I am trying to debug some crazy ThingWorx issues';
var myBoolean = myString.includes('ThingWorx');
*the above code will throw the error:
'TypeError: Cannot find function includes in object I am trying to debug some crazy ThingWorx issues. (GetProcessPartID#22)]'
But if I log 'typeof myString', it will log 'string'.
What gives?!
Solved! Go to Solution.
The .includes() function is not available.
Use .indexOf() instead:
(myString.indexOf('ThingWorx') != -1)
The .includes() function is not available.
Use .indexOf() instead:
(myString.indexOf('ThingWorx') != -1)
Is there a rhyme or reason to why some javascript methods are available and others not?
Yes, ThingWorx uses a custom version of Rhino for JavaScript processing in Services that conforms (with some exceptions) to the ECMAScript 5 specification.The ECMAScript 5 Specification can be found here.
Thank you! This is very helpful!